📄 indicationformatter.cpp
字号:
Boolean isArray = propertyValue.isArray(); if (isArray) { PEG_METHOD_EXIT(); return _getArrayValues( propertyValue, arrayIndexStr, contentLangs); } else // value is not an array {#if defined(PEGASUS_HAS_ICU) && defined(PEGASUS_INDFORMATTER_USE_ICU) if (canLocalize) { if (type == CIMTYPE_DATETIME) { CIMDateTime dateTimeValue; propertyValue.get(dateTimeValue); PEG_METHOD_EXIT(); return _localizeDateTime(dateTimeValue, locale); } else if (type == CIMTYPE_BOOLEAN) { Boolean booleanValue; propertyValue.get(booleanValue); PEG_METHOD_EXIT(); return _localizeBooleanStr(booleanValue, locale); } else { PEG_METHOD_EXIT(); return propertyValue.toString(); } } else { if (type == CIMTYPE_BOOLEAN) { PEG_METHOD_EXIT(); return _getBooleanStr(propertyValue); } else { PEG_METHOD_EXIT(); return propertyValue.toString(); } }#else if (type == CIMTYPE_BOOLEAN) { PEG_METHOD_EXIT(); return _getBooleanStr(propertyValue); } else { PEG_METHOD_EXIT(); return propertyValue.toString(); }#endif } } else // value is NULL { PEG_METHOD_EXIT(); return "NULL"; } } propertyName.clear(); } PEG_METHOD_EXIT(); return "UNKNOWN";}String IndicationFormatter::_getArrayValues( const CIMValue& propertyValue, const String& arrayIndexStr, const ContentLanguageList& contentLangs){ PEG_METHOD_ENTER(TRC_IND_FORMATTER, "IndicationFormatter::_getArrayValues"); CIMType type = propertyValue.getType(); String arrayValues; char propertyValueBuffer[2048]; Uint32 arraySize = propertyValue.getArraySize(); char arrayIndexBuffer[16]; Sint32 arrayIndex = 0; Uint32 sizeOfArrayIndexStr = arrayIndexStr.size(); // there is an index value enclosed in brackets (e.g. [2]) if (sizeOfArrayIndexStr != 0) { sprintf(arrayIndexBuffer, "%s", (const char *) arrayIndexStr.getCString()); try { _isValidIndex(arrayIndexBuffer); arrayIndex = atoi(arrayIndexBuffer); } catch (CIMException& c) { arrayIndex = -1; PEG_TRACE_STRING(TRC_IND_FORMATTER, Tracer::LEVEL4, c.getMessage()); } } // Array index is out of range if (sizeOfArrayIndexStr != 0 && ((arrayIndex < 0) || ((Uint32)arrayIndex >= arraySize))) { arrayValues = "UNKNOWN"; PEG_METHOD_EXIT(); return arrayValues; } switch (type) { case CIMTYPE_UINT8: { Array<Uint8> propertyValueUint8; propertyValue.get(propertyValueUint8); // Empty brackets (e.g. []), gets all values of the array if (sizeOfArrayIndexStr == 0) { arrayValues.append("["); for (Uint32 i=0; i<arraySize; i++) { sprintf(propertyValueBuffer, "%u", propertyValueUint8[i]); arrayValues.append(propertyValueBuffer); if ( i < arraySize-1) { arrayValues.append(","); } } arrayValues.append("]"); } else { sprintf(propertyValueBuffer, "%u", propertyValueUint8[arrayIndex]); arrayValues = propertyValueBuffer; } break; } case CIMTYPE_UINT16: { Array<Uint16> propertyValueUint16; propertyValue.get(propertyValueUint16); // Empty brackets (e.g. []), gets all values of the array if (sizeOfArrayIndexStr == 0) { arrayValues.append("["); for (Uint32 i=0; i<arraySize; i++) { sprintf(propertyValueBuffer, "%u", propertyValueUint16[i]); arrayValues.append(propertyValueBuffer); if ( i < arraySize-1) { arrayValues.append(","); } } arrayValues.append("]"); } else { sprintf(propertyValueBuffer, "%u", propertyValueUint16[arrayIndex]); arrayValues = propertyValueBuffer; } break; } case CIMTYPE_UINT32: { Array<Uint32> propertyValueUint32; propertyValue.get(propertyValueUint32); // Empty brackets (e.g. []), gets all values of the array if (sizeOfArrayIndexStr == 0) { arrayValues.append("["); for (Uint32 i=0; i<arraySize; i++) { sprintf(propertyValueBuffer, "%u", propertyValueUint32[i]); arrayValues.append(propertyValueBuffer); if ( i < arraySize-1) { arrayValues.append(","); } } arrayValues.append("]"); } else { sprintf(propertyValueBuffer, "%u", propertyValueUint32[arrayIndex]); arrayValues = propertyValueBuffer; } break; } case CIMTYPE_UINT64: { Array<Uint64> propertyValueUint64; propertyValue.get(propertyValueUint64); // Empty brackets (e.g. []), gets all values of the array if (sizeOfArrayIndexStr == 0) { arrayValues.append("["); for (Uint32 i=0; i<arraySize; i++) { sprintf(propertyValueBuffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", propertyValueUint64[i]); arrayValues.append(propertyValueBuffer); if ( i < arraySize-1) { arrayValues.append(","); } } arrayValues.append("]"); } else { sprintf(propertyValueBuffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", propertyValueUint64[arrayIndex]); arrayValues = propertyValueBuffer; } break; } case CIMTYPE_SINT8: { Array<Sint8> propertyValueSint8; propertyValue.get(propertyValueSint8); // Empty brackets (e.g. []), gets all values of the array if (sizeOfArrayIndexStr == 0) { arrayValues.append("["); for (Uint32 i=0; i<arraySize; i++) { sprintf(propertyValueBuffer, "%i", propertyValueSint8[i]); arrayValues.append(propertyValueBuffer); if ( i < arraySize-1) { arrayValues.append(","); } } arrayValues.append("]"); } else { sprintf(propertyValueBuffer, "%i", propertyValueSint8[arrayIndex]); arrayValues = propertyValueBuffer; } break; } case CIMTYPE_SINT16: { Array<Sint16> propertyValueSint16; propertyValue.get(propertyValueSint16); // Empty brackets (e.g. []), gets all values of the array if (sizeOfArrayIndexStr == 0) { arrayValues.append("["); for (Uint32 i=0; i<arraySize; i++) { sprintf(propertyValueBuffer, "%i", propertyValueSint16[i]); arrayValues.append(propertyValueBuffer); if ( i < arraySize-1) { arrayValues.append(","); } } arrayValues.append("]"); } else { sprintf(propertyValueBuffer, "%i", propertyValueSint16[arrayIndex]); arrayValues = propertyValueBuffer; } break; } case CIMTYPE_SINT32: { Array<Sint32> propertyValueSint32; propertyValue.get(propertyValueSint32); // Empty brackets (e.g. []), gets all values of the array if (sizeOfArrayIndexStr == 0) { arrayValues.append("["); for (Uint32 i=0; i<arraySize; i++) { sprintf(propertyValueBuffer, "%i", propertyValueSint32[i]); arrayValues.append(propertyValueBuffer); if ( i < arraySize-1) { arrayValues.append(","); } } arrayValues.append("]"); } else { sprintf(propertyValueBuffer, "%i", propertyValueSint32[arrayIndex]); arrayValues = propertyValueBuffer; } break; } case CIMTYPE_SINT64: { Array<Sint64> propertyValueSint64; propertyValue.get(propertyValueSint64); // Empty brackets (e.g. []), gets all values of the array if (sizeOfArrayIndexStr == 0) { arrayValues.append("["); for (Uint32 i=0; i<arraySize; i++) { sprintf(propertyValueBuffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "d", propertyValueSint64[i]); arrayValues.append(propertyValueBuffer); if ( i < arraySize-1) { arrayValues.append(","); } } arrayValues.append("]"); } else { sprintf(propertyValueBuffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "d", propertyValueSint64[arrayIndex]); arrayValues = propertyValueBuffer; } break; } case CIMTYPE_REAL32: { Array<Real32> propertyValueReal32; propertyValue.get(propertyValueReal32); // Empty brackets (e.g. []), gets all values of the array if (sizeOfArrayIndexStr == 0) { arrayValues.append("["); for (Uint32 i=0; i<arraySize; i++) { sprintf(propertyValueBuffer, "%f", propertyValueReal32[i]); arrayValues.append(propertyValueBuffer); if ( i < arraySize-1) { arrayValues.append(","); } } arrayValues.append("]"); } else { sprintf(propertyValueBuffer, "%f", propertyValueReal32[arrayIndex]); arrayValues = propertyValueBuffer; } break; } case CIMTYPE_REAL64: { Array<Real64> propertyValueReal64; propertyValue.get(propertyValueReal64); // Empty brackets (e.g. []), gets all values of the array if (sizeOfArrayIndexStr == 0) { arrayValues.append("["); for (Uint32 i=0; i<arraySize; i++) { sprintf(propertyValueBuffer, "%f", propertyValueReal64[i]); arrayValues.append(propertyValueBuffer); if ( i < arraySize-1) { arrayValues.append(","); } } arrayValues.append("]"); } else { sprintf(propertyValueBuffer, "%f", propertyValueReal64[arrayIndex]); arrayValues = propertyValueBuffer; } break; } case CIMTYPE_BOOLEAN: { Array<Boolean> booleanValue; propertyValue.get(booleanValue);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -