// ----------------------------------------------------------------------- // getTextLength: // ----------------------------------------------------------------------- const Lng32 CatApiRequest::getTextLength( void ) const { #pragma nowarn(1506) // warning elimination Lng32 length = ( strlen( CATAPI ) + strlen( APIVERSION ) +1 /*space*/); #pragma warn(1506) // warning elimination char buf[100]; length = length + (sprintf( buf, "%d", LAST_API_REQUEST)); length++; // space length = length + (sprintf( buf, "%d", getNumParams() )); length++; //space const CatApiParam *nextParam = getFirstParam(); for (Lng32 i = 0; i < getNumParams(); i++) { assert (nextParam); length += nextParam->getParamLength(); if (strcmp( versionInfo_, APIVERSION ) == 0) length += sizeof(MAXPARAMSIZE) + 1; // length bytes + 1 for space else length += 3; // begin/end delimiter, space nextParam = nextParam->getNextParam(); } length = length + 2; // ; plus null terminator return length; }
// ----------------------------------------------------------------------- // getText: // // returns TRUE is successful, FALSE otherwise // ----------------------------------------------------------------------- short CatApiRequest::getText( char *text, const short includeSemicolon ) const { size_t strPos = 0; text[0] = '\0'; // Add statement header strcat( text, CATAPI); strPos = strPos + strlen(CATAPI); // Add version information. Always version 2; the code below // cannot produce version 1 parameters. strcat( text, APIVERSION ); strPos = strPos + strlen(APIVERSION); text[strPos++] = ' '; // add request type size_t length = sprintf( &text[strPos], "%0d", getCatApiRequestType() ); strPos = strPos + length; text[strPos++] = ' '; // Add number parameters length = sprintf( &text[strPos], "%0d", getNumParams() ); strPos = strPos + length; text[strPos++] = ' '; // Add each parameter // Parameters are of the form: length space value const CatApiParam *ptrParam = getFirstParam(); for (Int32 i = 0; i < getNumParams(); i++) { if (!ptrParam) return 0; // add length + space length = sprintf( &text[strPos], "%0d", ptrParam->getParamLengthForMsg() ); strPos += length; text[strPos++] = ' '; // add parameter + space strcpy( &text[strPos], ptrParam->getParamValue() ); strPos += ptrParam->getParamLength(); if (ptrParam->getParamLength() > 0) text[strPos++] = ' '; ptrParam = ptrParam->getNextParam(); } if (includeSemicolon) text[strPos++] = ';'; text[strPos] = '\0'; return 1; }
std::string Solver::settingsPyDictRepr() const { std::stringstream ss; for(int n=0; n<getNumParams(); ++n) ss << (n ? ", " : "") << "'" << getParamName(n) << "': " << getValue(getParamName(n)).pythonRepr(); return ss.str(); }
std::string Solver::getSettingsRepr() const { std::stringstream ss; for(int n=0; n<getNumParams(); ++n) ss << " " << std::setw(20) << getParamName(n) << ": " << getValue(getParamName(n)).toString() << "\n"; return ss.str(); }
// ----------------------------------------------------------------------- // CatApiRequest::operator[]() -- const version // ----------------------------------------------------------------------- const CatApiParam * CatApiRequest::operator[] (Lng32 index) const { if ((index < 0) || (index > getNumParams()-1)) return NULL; const CatApiParam *nextParam = getFirstParam(); for (Lng32 i = 0; i < getNumParams(); i++) { if (i == index) return nextParam; if (nextParam == NULL) return NULL; nextParam = nextParam->getNextParam(); } return NULL; }
void printMap (PE_MAP *map) { assert (map); printf ("%s{", map->type_name); printPhraseArr (map->phrases, getNumParams (map->type_name)); printf ("}"); }
/* Function: displayIdentifierAttributes() const Description: This function will print out all of the attributes associated with a symbol table entry. */ void symbolTableEntry::displayIdentifierAttributes(int tabCount) const { int idNumTemp = 0; std::string idTemp = getIdentifierName(); printTabs(tabCount); std::cout << "Identifier name: " << idTemp << std::endl; idTemp = getIdentifierType_String(); printTabs(tabCount); std::cout << "Identifier type: " << idTemp << std::endl; printTabs(tabCount); std::cout << "Identifier value: "; printIdentifierValue(); std::cout << std::endl; //!!!!!!!!!!!!!!!!! CHECK THIS LATER !!!!!!!!!!! if (isFunc) { idNumTemp = getNumParams(); std::cout << "Identifier is a function." << std::endl; std::cout << "Identifier has " << idNumTemp << " parameters."; std::cout << std::endl; std::cout << "Identifier parameters: " << std::endl; viewParams(); } else if (isPtr) { idNumTemp = getNumPtrs(); std::cout << "Identifier is a pointer." << std::endl; std::cout << "Identifier has " << idNumTemp << " parameters."; std::cout << std::endl; } else if (isArr) { idNumTemp = getNumArrDims(); std::cout << "Identifier is an array." << std::endl; std::cout << "Identifier has " << idNumTemp << " dimensions."; std::cout << std::endl; std::cout << "Identifier dimensions: " << std::endl; for (unsigned int i = 0; i < arrayDimensions.size(); i++) { std::cout << "Dimension #" << i << " :" << arrayDimensions[i] << std::endl; } } }