[267] | 1 | #include "variable.hpp" |
---|
| 2 | |
---|
| 3 | #include "attribute_template_impl.hpp" |
---|
| 4 | #include "object_template_impl.hpp" |
---|
| 5 | #include "group_template_impl.hpp" |
---|
| 6 | |
---|
| 7 | #include "object_factory.hpp" |
---|
| 8 | #include "object_factory_impl.hpp" |
---|
| 9 | |
---|
| 10 | namespace xmlioserver { |
---|
| 11 | namespace tree { |
---|
| 12 | |
---|
| 13 | /// ////////////////////// Définitions ////////////////////// /// |
---|
| 14 | |
---|
| 15 | CVariable::CVariable(void) |
---|
| 16 | : CObjectTemplate<CVariable>() |
---|
| 17 | , CVariableAttributes() |
---|
[272] | 18 | , content() |
---|
[267] | 19 | { /* Ne rien faire de plus */ } |
---|
| 20 | |
---|
| 21 | CVariable::CVariable(const StdString & id) |
---|
| 22 | : CObjectTemplate<CVariable>(id) |
---|
| 23 | , CVariableAttributes() |
---|
[272] | 24 | , content() |
---|
[267] | 25 | { /* Ne rien faire de plus */ } |
---|
| 26 | |
---|
| 27 | CVariable::~CVariable(void) |
---|
| 28 | { /* Ne rien faire de plus */ } |
---|
| 29 | |
---|
| 30 | StdString CVariable::GetName(void) { return (StdString("variable")); } |
---|
| 31 | StdString CVariable::GetDefName(void){ return (CVariable::GetName()); } |
---|
| 32 | ENodeType CVariable::GetType(void) { return (eVariable); } |
---|
| 33 | |
---|
[272] | 34 | void CVariable::parse(xml::CXMLNode & node) |
---|
| 35 | { |
---|
| 36 | SuperClass::parse(node); |
---|
| 37 | StdString id = (this->hasId()) ? this->getId() : StdString("undefined"); |
---|
| 38 | if (!node.getContent(this->content)) |
---|
| 39 | { |
---|
| 40 | ERROR("CVariable::parse(xml::CXMLNode & node)", |
---|
| 41 | << "[ variable id = " << id |
---|
| 42 | << " ] variable is not defined !"); |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | const StdString & CVariable::getContent (void) const |
---|
| 47 | { |
---|
| 48 | return (this->content); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | StdString CVariable::toString(void) const |
---|
| 52 | { |
---|
| 53 | StdOStringStream oss; |
---|
| 54 | |
---|
| 55 | oss << "<" << CVariable::GetName() << " "; |
---|
| 56 | if (this->hasId()) |
---|
| 57 | oss << " id=\"" << this->getId() << "\" "; |
---|
| 58 | oss << SuperClassAttribute::toString() << ">" << std::endl |
---|
| 59 | << this->content /*<< std::endl*/; |
---|
| 60 | oss << "</" << CVariable::GetName() << " >"; |
---|
| 61 | return (oss.str()); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | void CVariableGroup::parse(xml::CXMLNode & node, bool withAttr) |
---|
| 65 | { |
---|
| 66 | boost::shared_ptr<CVariableGroup> group_ptr = (this->hasId()) |
---|
| 67 | ? CObjectFactory::GetObject<CVariableGroup>(this->getId()) |
---|
| 68 | : CObjectFactory::GetObject(this); |
---|
| 69 | |
---|
| 70 | StdString content; |
---|
| 71 | if (this->getId().compare(CVariableGroup::GetDefName()) != 0 && node.getContent(content)) |
---|
| 72 | { |
---|
| 73 | StdSize beginid = 0, endid = 0, begindata = 0, enddata = 0; |
---|
| 74 | StdString subdata, subid; |
---|
| 75 | |
---|
| 76 | while ((beginid = content.find_first_not_of ( " \r\n\t;", enddata)) != StdString::npos) |
---|
| 77 | { |
---|
| 78 | endid = content.find_first_of ( " \r\n\t=", beginid ); |
---|
| 79 | subid = content.substr ( beginid, endid-beginid); |
---|
| 80 | |
---|
| 81 | begindata = content.find_first_of ( "=", endid ) + 1; |
---|
| 82 | enddata = content.find_first_of ( ";", begindata ); |
---|
| 83 | subdata = content.substr ( begindata, enddata-begindata); |
---|
| 84 | |
---|
| 85 | //std::cout << "\"" << subid << "\":\"" << subdata << "\"" << std::endl; |
---|
| 86 | CGroupFactory::CreateChild(group_ptr, subid)->content = subdata; |
---|
| 87 | } |
---|
| 88 | } |
---|
| 89 | else |
---|
| 90 | { |
---|
| 91 | SuperClass::parse(node, withAttr); |
---|
| 92 | } |
---|
| 93 | //SuperClass::parse(node, withAttr); |
---|
| 94 | |
---|
| 95 | } |
---|
| 96 | |
---|
[267] | 97 | } // namespace tree |
---|
| 98 | } // namespace xmlioserver |
---|