// Helper method to set the jsonValue for a specific group void JsonValue::setValueFromEXTfldval(tThreadData* pThreadData, EXTfldval &fVal, std::string group) { (*jsonValue)[group] = Json::Value(); // Get the data type of the parameter ffttype valType; fVal.getType(valType); // Perform appropriate initialization for each type if (valType == fftCharacter) { (*jsonValue)[group] = getStringFromEXTFldVal(fVal); } else if (valType == fftInteger) { (*jsonValue)[group] = getIntFromEXTFldVal(fVal); } else if (valType == fftNumber) { (*jsonValue)[group] = getDoubleFromEXTFldVal(fVal); } else if (valType == fftBoolean) { (*jsonValue)[group] = getBoolFromEXTFldVal(fVal); } else if (valType == fftDate) { (*jsonValue)[group] = getISO8601DateStringFromEXTFldVal(fVal); } // If no parameters were passed or an object couldn't be found, then init to NULL if ( (*jsonValue)[group].isNull() ) { (*jsonValue)[group] = Json::Value(); } }
// Convenience method to return the type of an EXTfldval OmnisTools::FieldValType OmnisTools::getType( EXTfldval& fVal ) { OmnisTools::FieldValType retType; fVal.getType(retType.valType, &retType.valSubType); return retType; }
boost::any OmnisTools::getAnyFromEXTFldVal(EXTfldval& val) { // Get column definition type ffttype fft; qshort fdp; val.getType( fft, &fdp ); str255 colName; EXTqlist *listVal; EXTfldval colVal, colTitleVal; std::vector<ParamMap> listVector; boost::any ret; // Assign map based on definition switch (fft) { case fftCharacter: ret = getStringFromEXTFldVal(val); break; case fftInteger: ret = getIntFromEXTFldVal(val); break; case fftNumber: ret = getDoubleFromEXTFldVal(val); break; case fftBoolean: ret = getBoolFromEXTFldVal(val); break; case fftBinary: ret = getBinaryVectorFromEXTFldVal(val); break; case fftRow: case fftList: listVal = val.getList(qfalse); listVector.clear(); for( qlong curRow = 1; curRow < listVal->rowCnt(); ++curRow ) { ParamMap row; for( qlong curCol = 1; curCol < listVal->colCnt(); ++curCol ) { listVal->getCol(curCol, qfalse, colName); colTitleVal.setChar(colName); listVal->getColValRef(curRow, curCol, colVal, qfalse); row[getStringFromEXTFldVal(colTitleVal)] = getAnyFromEXTFldVal(colVal); } listVector.push_back(row); } ret = listVector; break; default: LOG_DEBUG << "Unknown column type when converting parameters."; break; } return ret; }
// Helper method to set the jsonValue for a specific array position void JsonValue::setValueFromEXTfldval(tThreadData* pThreadData, EXTfldval &fVal, int group) { // Get the data type of the parameter ffttype valType; fVal.getType(valType); // Perform appropriate initialization for each type if (valType == fftCharacter) { (*jsonValue)[group] = getStringFromEXTFldVal(fVal); } else if (valType == fftInteger) { (*jsonValue)[group] = getIntFromEXTFldVal(fVal); } else if (valType == fftNumber) { (*jsonValue)[group] = getDoubleFromEXTFldVal(fVal); } else if (valType == fftBoolean) { (*jsonValue)[group] = getBoolFromEXTFldVal(fVal); } else if (valType == fftDate) { (*jsonValue)[group] = getISO8601DateStringFromEXTFldVal(fVal); } }
// Helper method to initialize the jsonValue to a new value. void JsonValue::setValueFromEXTfldval(tThreadData* pThreadData, EXTfldval &fVal) { // Get the data type of the parameter ffttype valType; fVal.getType(valType); // Perform appropriate initialization for each type if (valType == fftCharacter) { *jsonValue = getStringFromEXTFldVal(fVal); } else if (valType == fftInteger) { *jsonValue = getIntFromEXTFldVal(fVal); } else if (valType == fftNumber) { *jsonValue = getDoubleFromEXTFldVal(fVal); } else if (valType == fftBoolean) { *jsonValue = getBoolFromEXTFldVal(fVal); } else if (valType == fftDate) { *jsonValue = getISO8601DateStringFromEXTFldVal(fVal); } else if (valType == fftObject) { JsonValue* assignObj = getObjForEXTfldval<JsonValue>(pThreadData, fVal); if (assignObj) { *jsonValue = *(assignObj->jsonValue); } } }
qbool OmnisTools::isList( EXTfldval& pFVal, qbool pCanBeRow ) { ffttype fft; pFVal.getType(fft); return ( (fft == fftList || (pCanBeRow && fft == fftRow)) ? qtrue : qfalse ); }