const ConcreteValueBase* ESolver::CreateValue(const ESFixedTypeBase* Type, const string& ValueString) { switch(Type->GetBaseType()) { case BaseTypeBool: return CreateValue(Type, ParseBoolString(ValueString)); case BaseTypeInt: return CreateValue(Type, ParseIntString(ValueString)); case BaseTypeEnum: return CreateValue(Type, ParseEnumString(ValueString, Type)); case BaseTypeBitVector: return CreateValue(Type, ParseBVString(ValueString, Type->As<ESBVType>()->GetSize())); default: throw TypeException("Unhandled type in CreateValue()"); } }
/*! * \brief Sets a string parameter named `name` * * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter * \param value The string value */ void ParameterList::SetParameter(const String& name, const char* value) { Parameter& parameter = CreateValue(name); parameter.type = ParameterType_String; PlacementNew(¶meter.value.stringVal, value); }
virtual void sync_new(const wchar_t** pszAbsPath, bool bNewValue) { m_pStorage->region_load(pszAbsPath, true); CAutoPtr<BoolValue> pBoolValue; CreateValue(bNewValue, &pBoolValue); m_pStorage->attr_put(c_wstrNew, pBoolValue); };
const ConstOperator* ESolver::CreateConstant(const string& ConstantName, const ESFixedTypeBase* Type, const string& ConstantString) { const ConcreteValueBase* TheValue = CreateValue(Type, ConstantString); return CreateConstant(ConstantName, TheValue); }
/*! * \brief Sets a color parameter named `name` * * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter * \param value The color value */ void ParameterList::SetParameter(const String& name, const Color& value) { Parameter& parameter = CreateValue(name); parameter.type = ParameterType_Color; PlacementNew(¶meter.value.colorVal, value); }
I_Value* CreateValue_Text( vuint16 inFlags, I_Localizable_Ptr inLocalizable, bool inIsRemote ) { return CreateValue( kTypeText, inFlags, nullptr, inLocalizable.get(), inIsRemote ); }
void sync_changed(const wchar_t** pszAbsPath, bool bChangedValue) { m_pStorage->region_load(pszAbsPath, true); CAutoPtr<BoolValue> pBoolValue; CreateValue(bChangedValue, &pBoolValue); m_pStorage->attr_put(c_wstrChanged, pBoolValue); };
I_Value* CreateValue_VarChar( vuint16 inFlags, tslen inMaxLen, I_Localizable_Ptr inLocalizable, bool inIsRemote ) { return CreateValue( kTypeVarChar, inFlags, &inMaxLen, inLocalizable.get(), inIsRemote ); }
UTF16String *CreateValue(PATH_SEGMENT_ITER iterSegBegin, PATH_SEGMENT_ITER iterSegEnd){ if(iterSegBegin == iterSegEnd){ return nullptr; } auto iterName = iterSegEnd; --iterName; const auto ppkgParent = CreatePackage(iterSegBegin, iterName); return ppkgParent->CreateValue(*iterName); }
AAFRESULT STDMETHODCALLTYPE ImplAAFTypeDefArray::CreateEmptyValue (ImplAAFPropertyValue ** ppPropVal) { AAFRESULT result = AAFRESULT_SUCCESS; if (NULL == ppPropVal) return AAFRESULT_NULL_PARAM; ImplAAFTypeDefSP pElementType; result = GetType(&pElementType); if (AAFRESULT_FAILED(result)) return result; if (dynamic_cast<ImplAAFTypeDefStrongObjRef*>((ImplAAFTypeDef*) pElementType)) { // element is strong ref ImplAAFStrongRefArrayValue* pStrongRefArray = NULL; pStrongRefArray = (ImplAAFStrongRefArrayValue*) CreateImpl (CLSID_AAFStrongRefArrayValue); if (!pStrongRefArray) return AAFRESULT_NOMEMORY; result = pStrongRefArray->Initialize(this, kAAFTrue == IsFixedSize()); if (AAFRESULT_SUCCEEDED(result)) { *ppPropVal = pStrongRefArray; } else { pStrongRefArray->ReleaseReference(); } } else if (dynamic_cast<ImplAAFTypeDefWeakObjRef*>((ImplAAFTypeDef*) pElementType)) { // element is weak ref ImplAAFWeakRefArrayValue* pWeakRefArray = NULL; pWeakRefArray = (ImplAAFWeakRefArrayValue*) CreateImpl (CLSID_AAFWeakRefArrayValue); if (!pWeakRefArray) return AAFRESULT_NOMEMORY; result = pWeakRefArray->Initialize(this, kAAFTrue == IsFixedSize()); if (AAFRESULT_SUCCEEDED(result)) { *ppPropVal = pWeakRefArray; } else { pWeakRefArray->ReleaseReference(); } } else { //simply defer to base impl (size is 0) result = CreateValue(ppPropVal); } return result; }
bool HLXSListTest::HandleInsertAfterCmd(const UTVector<UTString>& info) { bool ret = false; int value = 0; if (!UTParamUtil::GetInt(info[1], value)) { DPRINTF(D_ERROR, ("npSList::HandleInsertAfterCmd : failed to convert parameter\n")); } else { m_pos = m_list.InsertAfter(m_pos, CreateValue(value)); ret = true; } return ret; }
bool HLXSListTest::HandleReplaceAtCmd(const UTVector<UTString>& info) { bool ret = false; int value = 0; if (!UTParamUtil::GetInt(info[1], value)) { DPRINTF(D_ERROR, ("npSList::HandleReplaceAtCmd : failed to convert parameter\n")); } else { DestroyValue(m_list.GetAt(m_pos)); m_list.GetAt(m_pos) = CreateValue(value); ret = true; } return ret; }
bool HLXSListTest::FindValue(int value, LISTPOSITION pos, void*& pValue) { bool ret = false; pValue = 0; for(; pos && !pValue; m_list.GetNext(pos)) { int cur = 0; if ((GetValue(m_list.GetAt(pos), cur)) && (cur == value)) pValue = m_list.GetAt(pos); } if (pValue == 0) { pValue = CreateValue(value); ret = true; } return ret; }
//***************************************************************************** //***************************************************************************** C_RegistryValue* C_RegistryNode::CreateValue(DWORD idx) { TCHAR* ValName = GetValueName(idx); return CreateValue(ValName); };
void SettingsManager::Init() { CreateValue(Settings::General_DesinerName, DAVA::VariantType(DAVA::String("nobody"))); CreateValue(Settings::General_RecentFilesCount, DAVA::VariantType((DAVA::int32) 5)); CreateValue(Settings::General_PreviewEnabled, DAVA::VariantType(false)); CreateValue(Settings::General_CompressionQuality, DAVA::VariantType((DAVA::int32)DAVA::TextureConverter::ECQ_DEFAULT), DAVA::InspDesc("Compression quality", GlobalEnumMap<DAVA::TextureConverter::eConvertQuality>::Instance())); CreateValue(Settings::General_MaterialEditor_SwitchColor0, DAVA::VariantType(DAVA::Color(0.0f, 1.0f, 0.0f, 1.0f))); CreateValue(Settings::General_MaterialEditor_SwitchColor1, DAVA::VariantType(DAVA::Color(1.0f, 0.0f, 0.0f, 1.0f))); CreateValue(Settings::General_MaterialEditor_LodColor0, DAVA::VariantType(DAVA::Color(0.9f, 0.9f, 0.9f, 1.0f))); CreateValue(Settings::General_MaterialEditor_LodColor1, DAVA::VariantType(DAVA::Color(0.7f, 0.7f, 0.7f, 1.0f))); CreateValue(Settings::General_MaterialEditor_LodColor2, DAVA::VariantType(DAVA::Color(0.5f, 0.5f, 0.5f, 1.0f))); CreateValue(Settings::General_MaterialEditor_LodColor3, DAVA::VariantType(DAVA::Color(0.3f, 0.3f, 0.3f, 1.0f))); CreateValue(Settings::General_HeighMaskTool_Color0, DAVA::VariantType(DAVA::Color(0.5f, 0.5f, 0.5f, 1.0f))); CreateValue(Settings::General_HeighMaskTool_Color1, DAVA::VariantType(DAVA::Color(0.0f, 0.0f, 0.0f, 1.0f))); CreateValue(Settings::Scene_GridStep, DAVA::VariantType(10.0f)); CreateValue(Settings::Scene_GridSize, DAVA::VariantType(600.0f)); CreateValue(Settings::Scene_CameraSpeed0, DAVA::VariantType(35.0f)); CreateValue(Settings::Scene_CameraSpeed1, DAVA::VariantType(100.0f)); CreateValue(Settings::Scene_CameraSpeed2, DAVA::VariantType(250.0f)); CreateValue(Settings::Scene_CameraSpeed3, DAVA::VariantType(400.0f)); CreateValue(Settings::Scene_CameraFOV, DAVA::VariantType(70.0f)); CreateValue(Settings::Scene_CameraNear, DAVA::VariantType(1.0f)); CreateValue(Settings::Scene_CameraFar, DAVA::VariantType(5000.0f)); CreateValue(Settings::Scene_SelectionSequent, DAVA::VariantType(false)); CreateValue(Settings::Scene_SelectionDrawMode, DAVA::VariantType((DAVA::int32) SS_DRAW_DEFAULT), DAVA::InspDesc("Selection draw modes", GlobalEnumMap<SelectionSystemDrawMode>::Instance(), DAVA::InspDesc::T_FLAGS)); CreateValue(Settings::Scene_CollisionDrawMode, DAVA::VariantType((DAVA::int32) CS_DRAW_DEFAULT), DAVA::InspDesc("Collision draw modes", GlobalEnumMap<CollisionSystemDrawMode>::Instance(), DAVA::InspDesc::T_FLAGS)); CreateValue(Settings::Scene_GizmoScale, DAVA::VariantType(DAVA::float32(1.0))); CreateValue(Settings::Scene_DebugBoxScale, DAVA::VariantType(DAVA::float32(1.0))); CreateValue(Settings::Scene_DebugBoxUserScale, DAVA::VariantType(DAVA::float32(1.0))); CreateValue(Settings::Scene_DebugBoxParticleScale, DAVA::VariantType(DAVA::float32(1.0))); CreateValue(Settings::Scene_Sound_SoundObjectDraw, DAVA::VariantType(false)); CreateValue(Settings::Scene_Sound_SoundObjectBoxColor, DAVA::VariantType(DAVA::Color(0.0f, 0.8f, 0.4f, 0.2f))); CreateValue(Settings::Scene_Sound_SoundObjectSphereColor, DAVA::VariantType(DAVA::Color(0.0f, 0.8f, 0.4f, 0.1f))); CreateValue(Settings::Internal_TextureViewGPU, DAVA::VariantType((DAVA::int32) DAVA::GPU_PNG)); CreateValue(Settings::Internal_LastProjectPath, DAVA::VariantType(DAVA::FilePath())); CreateValue(Settings::Internal_EditorVersion, DAVA::VariantType(DAVA::String("local build"))); CreateValue(Settings::Internal_CubemapLastFaceDir, DAVA::VariantType(DAVA::FilePath())); CreateValue(Settings::Internal_CubemapLastProjDir, DAVA::VariantType(DAVA::FilePath())); CreateValue(Settings::Internal_ParticleLastEmitterDir, DAVA::VariantType(DAVA::FilePath())); CreateValue(Settings::Internal_RecentFiles, DAVA::VariantType((DAVA::KeyedArchive *) NULL)); CreateValue(Settings::Internal_MaterialsLightViewMode, DAVA::VariantType((DAVA::int32) EditorMaterialSystem::LIGHTVIEW_ALL)); CreateValue(Settings::Internal_MaterialsShowLightmapCanvas, DAVA::VariantType((bool) false)); CreateValue(Settings::Internal_LicenceAccepted, DAVA::VariantType((bool) false)); CreateValue(Settings::Internal_LODEditorMode, DAVA::VariantType((bool) false)); CreateValue(DAVA::FastName("Internal/RunActionEventWidget/CurrentType"), DAVA::VariantType((DAVA::uint32)0)); CreateValue(DAVA::FastName("Internal/Beast/LightmapsDefaultDir"), DAVA::VariantType(DAVA::String("lightmaps"))); }
/*! * \brief Sets a userdata parameter named `name` * * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter * \param value The pointer value * \param destructor The destructor function to be called upon parameter suppression * * \remark The destructor is called once when all copies of the userdata are destroyed, which means you can safely copy the parameter list around. */ void ParameterList::SetParameter(const String& name, void* value, Destructor destructor) { Parameter& parameter = CreateValue(name); parameter.type = ParameterType_Userdata; parameter.value.userdataVal = new Parameter::UserdataValue(destructor, value); }
/*! * \brief Sets a pointer parameter named `name` * * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter * \param value The pointer value * * \remark This sets a raw pointer, this class takes no responsibility toward it, if you wish to destroy the pointed variable along with the parameter list, you should set a userdata */ void ParameterList::SetParameter(const String& name, void* value) { Parameter& parameter = CreateValue(name); parameter.type = ParameterType_Pointer; parameter.value.ptrVal = value; }
/*! * \brief Sets an integer parameter named `name` * * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter * \param value The integer value */ void ParameterList::SetParameter(const String& name, long long value) { Parameter& parameter = CreateValue(name); parameter.type = ParameterType_Integer; parameter.value.intVal = value; }
UTF16String *CreateValue(std::initializer_list<const wchar_t *> ilPath){ return CreateValue(ilPath.begin(), ilPath.end()); }
bool TransactionHandler::Insert(XNode* pxInsert, WebContext* pWebContext, Map* pMap) { XNode* pxLayer = pxInsert->GetFirstChild(); if(pxLayer==NULL) { return false; } const char* name = pxLayer->GetName(); Layer *pLayer = pMap->GetLayer(name); if(pLayer==NULL) { return false; } augeLayerType ltype = pLayer->GetType(); if(ltype != augeLayerFeature) { return false; } FeatureLayer* pFeatureLayer = NULL; pFeatureLayer = static_cast<FeatureLayer*>(pLayer); FeatureClass* pFeatureClass = NULL; pFeatureClass = pFeatureLayer->GetFeatureClass(); if(pFeatureClass==NULL) { return false; } Feature* pFeature = pFeatureClass->NewFeature(); if(pFeature==NULL) { return false; } GField *pField = NULL; GFields *pFields = pFeatureClass->GetFields(); const char* fname = NULL; GValue* pValue = NULL; XNode* pxNode = NULL; XNodeSet* pxNodeSet = pxLayer->GetChildren(); pxNodeSet->Reset(); while((pxNode=pxNodeSet->Next())!=NULL) { fname = pxNode->GetName(); pField = pFields->GetField(fname); if(pField!=NULL) { pValue = CreateValue(pxNode, pField); if(pValue!=NULL) { pFeature->SetValue(fname, pValue); } } } pxNodeSet->Release(); FeatureInsertCommand* cmd = pFeatureClass->CreateInsertCommand(); RESULTCODE rc = cmd->Insert(pFeature); AUGE_SAFE_RELEASE(pFeature); AUGE_SAFE_RELEASE(cmd); return !rc; }
/*! * \brief Sets a null parameter named `name` * * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter */ void ParameterList::SetParameter(const String& name) { Parameter& parameter = CreateValue(name); parameter.type = ParameterType_None; }
Expression ESolver::CreateExpression(const ESFixedTypeBase* Type, const string& ConstantString) { const ConcreteValueBase* TheValue = CreateValue(Type, ConstantString); return CreateExpression(TheValue); }
/*! * \brief Sets a boolean parameter named `name` * * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter * \param value The boolean value */ void ParameterList::SetParameter(const String& name, bool value) { Parameter& parameter = CreateValue(name); parameter.type = ParameterType_Boolean; parameter.value.boolVal = value; }
bool TransactionHandler::Insert(XNode* pxInsert, WebContext* pWebContext, FeatureWorkspace* pWorkspace) { XNode* pxType = pxInsert->GetFirstChild(); if(pxType==NULL) { return false; } GLogger* pLogger = augeGetLoggerInstance(); GError* pError = augeGetErrorInstance(); RESULTCODE rc = AG_FAILURE; const char* name = pxType->GetName(); FeatureClass* pFeatureClass = NULL; pFeatureClass = pWorkspace->OpenFeatureClass(name); if(pFeatureClass==NULL) { char msg[AUGE_MSG_MAX]; g_snprintf(msg, AUGE_MSG_MAX, "Fail to get FeatureClass [%s]", name); pLogger->Error(msg, __FILE__, __LINE__); pError->SetError(msg); return false; } Feature* pFeature = pFeatureClass->NewFeature(); if(pFeature==NULL) { return false; } GField *pField = NULL; GFields *pFields = pFeatureClass->GetFields(); const char* fname = NULL; bool ok = true; GValue* pValue = NULL; XNode* pxNode = NULL; XNodeSet* pxNodeSet = pxType->GetChildren(); pxNodeSet->Reset(); while((pxNode=pxNodeSet->Next())!=NULL) { fname = pxNode->GetName(); pField = pFields->GetField(fname); if(pField!=NULL) { pValue = CreateValue(pxNode, pField); if(pValue!=NULL) { pFeature->SetValue(fname, pValue); } else { char msg[AUGE_MSG_MAX]; g_snprintf(msg, AUGE_MSG_MAX, "Field [%s]: Invalid Value", fname); pLogger->Error(msg, __FILE__, __LINE__); pError->SetError(msg); ok = false; break; } } else { char msg[AUGE_MSG_MAX]; g_snprintf(msg, AUGE_MSG_MAX, "FeatureClss does not have Field [%s]", fname); pLogger->Error(msg, __FILE__, __LINE__); pError->SetError(msg); ok = false; break; } } pxNodeSet->Release(); if(ok) { FeatureInsertCommand* cmd = pFeatureClass->CreateInsertCommand(); rc = cmd->Insert(pFeature); AUGE_SAFE_RELEASE(cmd); } AUGE_SAFE_RELEASE(pFeature); AUGE_SAFE_RELEASE(pFeatureClass); return !rc; }
/*! * \brief Sets a double parameter named `name` * * If a parameter already exists with that name, it is destroyed and replaced by this call * * \param name Name of the parameter * \param value The double value */ void ParameterList::SetParameter(const String& name, double value) { Parameter& parameter = CreateValue(name); parameter.type = ParameterType_Double; parameter.value.doubleVal = value; }