1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_AttributeString.cpp
4 // Created: 25 august 2014
7 #include <Model_AttributeString.h>
8 #include <ModelAPI_AttributeString.h>
9 #include <ModelAPI_Attribute.h>
10 #include <ModelAPI_Data.h>
11 #include <ModelAPI_Object.h>
13 #include <Standard_TypeDef.hxx>
14 #include <TCollection_AsciiString.hxx>
15 #include <TCollection_ExtendedString.hxx>
19 void Model_AttributeString::setValue(const std::string& theValue)
21 TCollection_ExtendedString aValue(theValue.c_str());
22 if (!myIsInitialized || myString->Get() != aValue) {
23 myString->Set(aValue);
24 owner()->data()->sendAttributeUpdated(this);
28 std::string Model_AttributeString::value()
30 return TCollection_AsciiString(myString->Get()).ToCString();
33 Model_AttributeString::Model_AttributeString(TDF_Label& theLabel)
35 // check the attribute could be already presented in this doc (after load document)
36 myIsInitialized = theLabel.FindAttribute(TDataStd_Name::GetID(), myString) == Standard_True;
37 if (!myIsInitialized) {
38 // create attribute: not initialized by value yet, just empty string
39 myString = TDataStd_Name::Set(theLabel, TCollection_ExtendedString());