#include <form_elm.h>
Inheritance diagram for NLGEORGES::CFormElmVirtualStruct:
Definition at line 327 of file form_elm.h.
Public Types | |
enum | TEval { NoEval, Formula, Eval } |
Value evalution. More... | |
enum | TWhereIsNode { NodeForm, NodeParentForm, NodeDfn, NodeType } |
Where a node has been found. More... | |
enum | TWhereIsValue { ValueForm, ValueParentForm, ValueDefaultDfn, ValueDefaultType, Dummy = 0xffffffff } |
Where a value has been found. More... | |
Public Member Functions | |
bool | arrayDeleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool verbose, uint arrayIndex) const |
bool | arrayInsertNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool verbose, uint arrayIndex) const |
void | build (const CFormDfn *dfn) |
CFormElmVirtualStruct (CForm *form, CFormElm *parentNode, const CFormDfn *parentDfn, uint parentIndex) | |
void | clean () |
Reset contents. | |
bool | convertValue (NLMISC::CRGBA &result, const char *value) const |
bool | convertValue (bool &result, const char *value) const |
bool | convertValue (double &result, const char *value) const |
bool | convertValue (float &result, const char *value) const |
bool | convertValue (uint32 &result, const char *value) const |
bool | convertValue (sint32 &result, const char *value) const |
bool | convertValue (uint16 &result, const char *value) const |
bool | convertValue (sint16 &result, const char *value) const |
bool | convertValue (uint8 &result, const char *value) const |
bool | convertValue (sint8 &result, const char *value) const |
bool | createNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool &created) |
bool | deleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array) |
virtual bool | getArrayNode (UFormElm **result, uint arrayIndex) |
virtual bool | getArrayNode (const UFormElm **result, uint arrayIndex) const |
virtual bool | getArrayNodeName (std::string &result, uint arrayIndex) const |
Return the name of a table element. | |
virtual bool | getArraySize (uint &size) const |
Return true if the element is an array and fill size with the array size. | |
virtual bool | getArrayValue (NLMISC::CRGBA &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const |
Warning, only R, G and B members are filled, not A. | |
virtual bool | getArrayValue (bool &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const |
virtual bool | getArrayValue (double &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const |
virtual bool | getArrayValue (float &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const |
virtual bool | getArrayValue (uint32 &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const |
virtual bool | getArrayValue (sint32 &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const |
virtual bool | getArrayValue (uint16 &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const |
virtual bool | getArrayValue (sint16 &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const |
virtual bool | getArrayValue (uint8 &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const |
virtual bool | getArrayValue (sint8 &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const |
virtual bool | getArrayValue (std::string &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const |
void | getDependencies (std::set< std::string > &dependencies) const |
bool | getDfnName (std::string &dfnName) const |
Get the dfn filename for this virtual struct. Must be a virtual struct node. | |
CForm * | getForm () const |
void | getFormName (std::string &result, const CFormElm *child) const |
bool | getNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, bool &parentVDfnArray, bool verbose, uint32 round) const |
virtual bool | getNodeByName (UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round=0) |
virtual bool | getNodeByName (const UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round=0) const |
virtual UFormElm * | getParent () const |
UFormDfn * | getStructDfn () |
Return the struct dfn. | |
bool | getStructNode (uint element, UFormElm **result) |
Return a mutable element pointer. Can be NULL if the node doesn't exist. | |
bool | getStructNode (uint element, const UFormElm **result) const |
Return a const element pointer. Can be NULL if the node doesn't exist. | |
bool | getStructNodeName (uint element, std::string &result) const |
Return the element name. | |
bool | getStructSize (uint &size) const |
Return the struct size. | |
virtual bool | getValue (NLMISC::CRGBA &resultname, TEval evaluate) const |
Warning, only R, G and B members are filled, not A. | |
virtual bool | getValue (bool &resultname, TEval evaluate) const |
virtual bool | getValue (double &resultname, TEval evaluate) const |
virtual bool | getValue (float &resultname, TEval evaluate) const |
virtual bool | getValue (uint32 &resultname, TEval evaluate) const |
virtual bool | getValue (sint32 &resultname, TEval evaluate) const |
virtual bool | getValue (uint16 &resultname, TEval evaluate) const |
virtual bool | getValue (sint16 &resultname, TEval evaluate) const |
virtual bool | getValue (uint8 &resultname, TEval evaluate) const |
virtual bool | getValue (sint8 &resultname, TEval evaluate) const |
virtual bool | getValue (std::string &resultname, TEval evaluate) const |
virtual bool | getValueByName (NLMISC::CRGBA &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const |
Warning, only R, G and B members are filled, not A. | |
virtual bool | getValueByName (bool &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const |
virtual bool | getValueByName (double &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const |
virtual bool | getValueByName (float &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const |
virtual bool | getValueByName (uint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const |
virtual bool | getValueByName (sint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const |
virtual bool | getValueByName (uint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const |
virtual bool | getValueByName (sint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const |
virtual bool | getValueByName (uint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const |
virtual bool | getValueByName (sint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const |
virtual bool | getValueByName (std::string &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const |
virtual bool | isArray () const |
Return true if the element is an array. | |
virtual bool | isAtom () const |
Return true if the element is an atom. | |
bool | isStruct () const |
Return true if the element is a struct or a virtual struct. | |
bool | isUsed (const CForm *form) const |
bool | isVirtualStruct () const |
Return true if the element is a virtual struct. | |
void | read (xmlNodePtr node, CFormLoader &loader, const CFormDfn *dfn, CForm *form) |
void | read (xmlNodePtr node, CFormLoader &loader, CForm *form) |
virtual bool | setValueByName (NLMISC::CRGBA value, const char *name, bool *created) |
virtual bool | setValueByName (bool value, const char *name, bool *created) |
virtual bool | setValueByName (double value, const char *name, bool *created) |
virtual bool | setValueByName (float value, const char *name, bool *created) |
virtual bool | setValueByName (uint32 value, const char *name, bool *created) |
virtual bool | setValueByName (sint32 value, const char *name, bool *created) |
virtual bool | setValueByName (uint16 value, const char *name, bool *created) |
virtual bool | setValueByName (sint16 value, const char *name, bool *created) |
virtual bool | setValueByName (uint8 value, const char *name, bool *created) |
virtual bool | setValueByName (sint8 value, const char *name, bool *created) |
virtual bool | setValueByName (const char *value, const char *name, bool *created) |
void | unlink (CFormElm *child) |
virtual void | warning (bool exception, const char *function, const char *format,...) const |
xmlNodePtr | write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite=false) const |
virtual | ~CFormElmVirtualStruct () |
Static Public Member Functions | |
const char * | tokenize (const char *name, std::string &str, uint &errorIndex, uint &code) |
Data Fields | |
std::string | DfnFilename |
std::vector< CFormElmStructElm > | Elements |
NLMISC::CSmartPtr< CFormDfn > | FormDfn |
Protected Types | |
enum | TNodeAction { Return, Create, Delete } |
Static Protected Member Functions | |
bool | getIternalNodeByName (CForm *form, const char *name, const CFormDfn **parentDfn, uint &indexDfn, const CFormDfn **nodeDfn, const CType **nodeType, CFormElm **node, UFormDfn::TEntryType &type, bool &array, TNodeAction action, bool &created, bool &parentVDfnArray, bool verbose, uint32 round) |
void | warning (bool exception, const char *formName, const char *formFileName, const char *function, const char *format,...) |
Protected Attributes | |
CForm * | Form |
const CFormDfn * | ParentDfn |
uint | ParentIndex |
CFormElm * | ParentNode |
uint32 | Round |
|
Value evalution.
Definition at line 47 of file u_form_elm.h.
|
|
Definition at line 195 of file form_elm.h.
|
|
Where a node has been found.
Definition at line 55 of file u_form_elm.h.
00056 { 00057 NodeForm, 00058 NodeParentForm, 00059 NodeDfn, 00060 NodeType, 00061 }; |
|
Where a value has been found.
Definition at line 94 of file u_form_elm.h.
00095 { 00096 ValueForm, 00097 ValueParentForm, 00098 ValueDefaultDfn, 00099 ValueDefaultType, 00100 Dummy = 0xffffffff 00101 }; |
|
Definition at line 2134 of file form_elm.cpp. References uint.
02134 : CFormElmStruct (form, parentNode, parentDfn, parentIndex) 02135 { 02136 } |
|
Definition at line 332 of file form_elm.h.
00332 { } |
|
Delete an array node by name The index asked must be < the size of the array. Definition at line 719 of file form_elm.cpp. References NLGEORGES::CFormElm::Create, NLGEORGES::CFormElmArray::Elements, NLGEORGES::CFormElm::Form, NLGEORGES::CFormElm::getIternalNodeByName(), NLGEORGES::CFormElm::isArray(), nlassert, NLGEORGES_FIRST_ROUND, NLGEORGES::CFormElm::ParentDfn, NLGEORGES::CFormElm::ParentIndex, type, and uint.
00723 { 00724 // Get the node by name 00725 *parentDfn = ParentDfn; 00726 indexDfn = ParentIndex; 00727 *nodeDfn = NULL; 00728 *nodeType = NULL; 00729 *node = (CFormElm*)this; 00730 bool created; 00731 bool parentVDfnArray; 00732 if (getIternalNodeByName (Form, name, parentDfn, indexDfn, nodeDfn, nodeType, node, type, array, Create, created, parentVDfnArray, verbose, NLGEORGES_FIRST_ROUND)) 00733 { 00734 // Must be in the same form 00735 nlassert ((*node) && ((*node)->Form == Form)); 00736 00737 // Get its parent 00738 CFormElm *parentNode = (*node)->ParentNode; 00739 if (parentNode->isArray ()) 00740 { 00741 // Cast pointer 00742 CFormElmArray *array = safe_cast<CFormElmArray*>(parentNode); 00743 00744 // Valid index ? 00745 if (arrayIndex<array->Elements.size ()) 00746 { 00747 // Insert the element 00748 if (array->Elements[arrayIndex].Element) 00749 delete array->Elements[arrayIndex].Element; 00750 00751 // Erase the entry 00752 array->Elements.erase (array->Elements.begin () + arrayIndex); 00753 00754 // Ok 00755 return true; 00756 } 00757 } 00758 } 00759 return false; 00760 } |
|
Insert an array node by name The index asked must be < the size of the array. Definition at line 645 of file form_elm.cpp. References NLGEORGES::CFormElmStruct::build(), NLGEORGES::CFormElm::Create, NLGEORGES::CFormElmArray::Elements, NLGEORGES::CFormElm::Form, NLGEORGES::CFormElm::getIternalNodeByName(), NLGEORGES::CFormElm::isArray(), nlassert, NLGEORGES_FIRST_ROUND, nlstop, NLGEORGES::CFormElm::ParentDfn, NLGEORGES::CFormElm::ParentIndex, type, and uint.
00649 { 00650 // Get the node by name 00651 *parentDfn = ParentDfn; 00652 indexDfn = ParentIndex; 00653 *nodeDfn = NULL; 00654 *nodeType = NULL; 00655 *node = (CFormElm*)this; 00656 bool created; 00657 bool parentVDfnArray; 00658 if (getIternalNodeByName (Form, name, parentDfn, indexDfn, nodeDfn, nodeType, node, type, array, Create, created, parentVDfnArray, verbose, NLGEORGES_FIRST_ROUND)) 00659 { 00660 // Must be in the same form 00661 nlassert ((*node) && ((*node)->Form == Form)); 00662 00663 // Get its parent 00664 CFormElm *parentNode = (*node)->ParentNode; 00665 if (parentNode->isArray ()) 00666 { 00667 // Cast pointer 00668 CFormElmArray *array = safe_cast<CFormElmArray*>(parentNode); 00669 00670 // Valid index ? 00671 if (arrayIndex<array->Elements.size ()) 00672 { 00673 // Insert the element 00674 array->Elements.insert (array->Elements.begin() + arrayIndex); 00675 00676 // Create a new element 00677 00678 // The new element 00679 CFormElm *newelm = NULL; 00680 switch (type) 00681 { 00682 case UFormDfn::EntryType: 00683 { 00684 // Create an atom 00685 CFormElmAtom *atom = new CFormElmAtom (Form, array, *parentDfn, indexDfn); 00686 newelm = atom; 00687 } 00688 break; 00689 case UFormDfn::EntryDfn: 00690 { 00691 CFormElmStruct *_struct = new CFormElmStruct (Form, array, *parentDfn, indexDfn); 00692 _struct->build (*nodeDfn); 00693 newelm = _struct; 00694 } 00695 break; 00696 case UFormDfn::EntryVirtualDfn: 00697 // todo array of virtual struct 00698 //newelm = new CFormElmVirtualStruct (Form, array, *parentDfn, indexDfn); 00699 break; 00700 default: 00701 nlstop; 00702 } 00703 00704 nlassert (newelm); 00705 00706 // Set the element pointer 00707 array->Elements[arrayIndex].Element = newelm; 00708 00709 // Ok 00710 return true; 00711 } 00712 } 00713 } 00714 return false; 00715 } |
|
Definition at line 2002 of file form_elm.cpp. References NLGEORGES::CFormElmStruct::clean(), NLGEORGES::CFormDfn::countParentDfn(), NLGEORGES::CFormElmStruct::FormDfn, NLGEORGES::CFormDfn::getParentDfn(), and uint. Referenced by NLGEORGES::CFormElm::arrayInsertNodeByName(), NLGEORGES::CFormElm::getIternalNodeByName(), NLGEORGES::CFormElmStruct::read(), and NLGEORGES::CForm::read().
02003 { 02004 // Clean the form 02005 clean (); 02006 02007 // Set the DFN 02008 FormDfn = (CFormDfn*)dfn; 02009 02010 // Get the parents 02011 vector<const CFormDfn*> arrayDfn; 02012 arrayDfn.reserve (dfn->countParentDfn ()); 02013 dfn->getParentDfn (arrayDfn); 02014 02015 // Count element 02016 uint elementCount = 0; 02017 uint dfnIndex; 02018 for (dfnIndex=0; dfnIndex<arrayDfn.size(); dfnIndex++) 02019 { 02020 elementCount += arrayDfn[dfnIndex]->getNumEntry(); 02021 } 02022 02023 // Resize the element array 02024 Elements.resize (elementCount); 02025 02026 elementCount = 0; 02027 for (dfnIndex=0; dfnIndex<arrayDfn.size(); dfnIndex++) 02028 { 02029 // For each element 02030 for (uint elm=0; elm<arrayDfn[dfnIndex]->Entries.size(); elm++) 02031 { 02032 // Copy the name 02033 Elements[elementCount].Name = arrayDfn[dfnIndex]->Entries[elm].Name; 02034 elementCount++; 02035 } 02036 } 02037 } |
|
Reset contents.
Reimplemented from NLGEORGES::CFormElm. Definition at line 1701 of file form_elm.cpp. References uint. Referenced by NLGEORGES::CFormElmStruct::build().
|
|
Definition at line 657 of file form_elm.h. References NLMISC::CRGBA::B, NLMISC::clamp(), NLMISC::CRGBA::G, NLMISC::CRGBA::R, r, uint8, value, and NLGEORGES::CFormElm::warning().
00658 { 00659 float r, g, b; 00660 if (sscanf (value, "%f,%f,%f", &r, &g, &b) == 3) 00661 { 00662 NLMISC::clamp (r, 0.f, 255.f); 00663 NLMISC::clamp (g, 0.f, 255.f); 00664 NLMISC::clamp (b, 0.f, 255.f); 00665 result.R = (uint8)r; 00666 result.G = (uint8)g; 00667 result.B = (uint8)b; 00668 return true; 00669 } 00670 00671 // Error message 00672 warning (false, "convertValue", "Can't convert the string \"%s\" in RGB color.", value); 00673 00674 return false; 00675 } |
|
Definition at line 625 of file form_elm.h. References NLMISC::strlwr(), value, and NLGEORGES::CFormElm::warning().
00626 { 00627 int tmp; 00628 if (sscanf (value, "%d", &tmp) == 1) 00629 { 00630 result = tmp != 0; 00631 return true; 00632 } 00633 else 00634 { 00635 std::string temp = value; 00636 temp = NLMISC::strlwr (temp); 00637 if (strcmp (temp.c_str (), "true") == 0) 00638 { 00639 result = true; 00640 return true; 00641 } 00642 if (strcmp (temp.c_str (), "false") == 0) 00643 { 00644 result = false; 00645 return true; 00646 } 00647 } 00648 00649 // Error message 00650 warning (false, "convertValue", "Can't convert the string \"%s\" in boolean.", value); 00651 00652 return false; 00653 } |
|
Definition at line 607 of file form_elm.h. References value, and NLGEORGES::CFormElm::warning().
00608 { 00609 float tmp; 00610 if (sscanf (value, "%f", &tmp) == 1) 00611 { 00612 result = tmp; 00613 return true; 00614 } 00615 else 00616 { 00617 // Error message 00618 warning (false, "convertValue", "Can't convert the string \"%s\" in double.", value); 00619 } 00620 return false; 00621 } |
|
Definition at line 591 of file form_elm.h. References value, and NLGEORGES::CFormElm::warning().
00592 { 00593 if (sscanf (value, "%f", &result) == 1) 00594 { 00595 return true; 00596 } 00597 else 00598 { 00599 // Error message 00600 warning (false, "convertValue", "Can't convert the string \"%s\" in float.", value); 00601 } 00602 return false; 00603 } |
|
Definition at line 572 of file form_elm.h. References NLMISC::clamp(), sint32, uint32, value, and NLGEORGES::CFormElm::warning().
00573 { 00574 float tmp; 00575 if (sscanf (value, "%f", &tmp) == 1) 00576 { 00577 NLMISC::clamp (tmp, 0.f, 4294967295.f); 00578 result = (sint32)tmp; 00579 return true; 00580 } 00581 else 00582 { 00583 // Error message 00584 warning (false, "convertValue", "Can't convert the string \"%s\" in uint32.", value); 00585 } 00586 return false; 00587 } |
|
Definition at line 553 of file form_elm.h. References NLMISC::clamp(), sint32, value, and NLGEORGES::CFormElm::warning().
00554 { 00555 float tmp; 00556 if (sscanf (value, "%f", &tmp) == 1) 00557 { 00558 NLMISC::clamp (tmp, -2147483648.f, 2147483647.f); 00559 result = (sint32)tmp; 00560 return true; 00561 } 00562 else 00563 { 00564 // Error message 00565 warning (false, "convertValue", "Can't convert the string \"%s\" in sint32.", value); 00566 } 00567 return false; 00568 } |
|
Definition at line 534 of file form_elm.h. References NLMISC::clamp(), uint16, value, and NLGEORGES::CFormElm::warning().
00535 { 00536 float tmp; 00537 if (sscanf (value, "%f", &tmp) == 1) 00538 { 00539 NLMISC::clamp (tmp, 0.f, 65535.f); 00540 result = (uint16)tmp; 00541 return true; 00542 } 00543 else 00544 { 00545 // Error message 00546 warning (false, "convertValue", "Can't convert the string \"%s\" in uint16.", value); 00547 } 00548 return false; 00549 } |
|
Definition at line 515 of file form_elm.h. References NLMISC::clamp(), sint16, value, and NLGEORGES::CFormElm::warning().
00516 { 00517 float tmp; 00518 if (sscanf (value, "%f", &tmp) == 1) 00519 { 00520 NLMISC::clamp (tmp, -32768.f, 32767.f); 00521 result = (sint16)tmp; 00522 return true; 00523 } 00524 else 00525 { 00526 // Error message 00527 warning (false, "convertValue", "Can't convert the string \"%s\" in sint16.", value); 00528 } 00529 return false; 00530 } |
|
Definition at line 496 of file form_elm.h. References NLMISC::clamp(), uint8, value, and NLGEORGES::CFormElm::warning().
00497 { 00498 float tmp; 00499 if (sscanf (value, "%f", &tmp) == 1) 00500 { 00501 NLMISC::clamp (tmp, 0.f, 255.f); 00502 result = (uint8)tmp; 00503 return true; 00504 } 00505 else 00506 { 00507 // Error message 00508 warning (false, "convertValue", "Can't convert the string \"%s\" in uint8.", value); 00509 } 00510 return false; 00511 } |
|
Definition at line 477 of file form_elm.h. References NLMISC::clamp(), sint8, value, and NLGEORGES::CFormElm::warning(). Referenced by NLGEORGES::CFormElmArray::getArrayValue(), NLGEORGES::CFormElmAtom::getValue(), and NLGEORGES::CFormElm::getValueByName().
00478 { 00479 float tmp; 00480 if (sscanf (value, "%f", &tmp) == 1) 00481 { 00482 NLMISC::clamp (tmp, -128.f, 127.f); 00483 result = (sint8)tmp; 00484 return true; 00485 } 00486 else 00487 { 00488 // Error message 00489 warning (false, "convertValue", "Can't convert the string \"%s\" in sint8.", value); 00490 } 00491 return false; 00492 } |
|
Definition at line 596 of file form_elm.cpp. References NLGEORGES::CFormElm::Create, NLGEORGES::CFormElm::Form, NLGEORGES::CFormElm::getIternalNodeByName(), NLGEORGES_FIRST_ROUND, NLGEORGES::CFormElm::ParentDfn, NLGEORGES::CFormElm::ParentIndex, type, and uint. Referenced by NLGEORGES::CFormElm::setValueByName().
00600 { 00601 *parentDfn = ParentDfn; 00602 indexDfn = ParentIndex; 00603 *nodeDfn = NULL; 00604 *nodeType = NULL; 00605 *node = this; 00606 bool parentVDfnArray; 00607 return getIternalNodeByName (Form, name, parentDfn, indexDfn, nodeDfn, nodeType, node, type, array, Create, created, parentVDfnArray, true, NLGEORGES_FIRST_ROUND); 00608 } |
|
Delete a node by name. If the node already exist, return it Delete its parent if not used Definition at line 612 of file form_elm.cpp. References NLGEORGES::CFormElm::Delete, NLGEORGES::CFormElm::Form, NLGEORGES::CFormElm::getIternalNodeByName(), NLGEORGES_FIRST_ROUND, NLGEORGES::CFormElm::ParentDfn, NLGEORGES::CFormElm::ParentIndex, type, and uint.
00616 { 00617 *parentDfn = ParentDfn; 00618 indexDfn = ParentIndex; 00619 *nodeDfn = NULL; 00620 *nodeType = NULL; 00621 *node = this; 00622 bool created; 00623 bool parentVDfnArray; 00624 return getIternalNodeByName (Form, name, parentDfn, indexDfn, nodeDfn, nodeType, node, type, array, Delete, created, parentVDfnArray, true, NLGEORGES_FIRST_ROUND); 00625 } |
|
Get a array sub element mutable pointer. If return true, fill result with the arrayIndex cell's element pointer. Can be NULL if the node doesn't exist. Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 76 of file form_elm.cpp. References uint, and NLGEORGES::CFormElm::warning().
00077 { 00078 warning (false, "getArrayNode", "This node is not an array."); 00079 return false; 00080 }; |
|
Get a array sub element const pointer. If return true, fill result with the arrayIndex cell's element Can be NULL if the node doesn't exist. Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 68 of file form_elm.cpp. References uint, and NLGEORGES::CFormElm::warning().
00069 { 00070 warning (false, "getArrayNode", "This node is not an array."); 00071 return false; 00072 }; |
|
Return the name of a table element.
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 84 of file form_elm.cpp. References uint, and NLGEORGES::CFormElm::warning().
00085 { 00086 warning (false, "getArrayNodeName", "This node is not an array."); 00087 return false; 00088 } |
|
Return true if the element is an array and fill size with the array size.
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 60 of file form_elm.cpp. References size, uint, and NLGEORGES::CFormElm::warning().
00061 { 00062 warning (false, "getArraySize", "This node is not an array."); 00063 return false; 00064 }; |
|
Warning, only R, G and B members are filled, not A.
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 172 of file form_elm.cpp. References uint, and NLGEORGES::CFormElm::warning().
00173 { 00174 warning (false, "getArrayValue", "This node is not an array."); 00175 return false; 00176 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 164 of file form_elm.cpp. References uint, and NLGEORGES::CFormElm::warning().
00165 { 00166 warning (false, "getArrayValue", "This node is not an array."); 00167 return false; 00168 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 156 of file form_elm.cpp. References uint, and NLGEORGES::CFormElm::warning().
00157 { 00158 warning (false, "getArrayValue", "This node is not an array."); 00159 return false; 00160 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 148 of file form_elm.cpp. References uint, and NLGEORGES::CFormElm::warning().
00149 { 00150 warning (false, "getArrayValue", "This node is not an array."); 00151 return false; 00152 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 140 of file form_elm.cpp. References uint, uint32, and NLGEORGES::CFormElm::warning().
00141 { 00142 warning (false, "getArrayValue", "This node is not an array."); 00143 return false; 00144 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 132 of file form_elm.cpp. References sint32, uint, and NLGEORGES::CFormElm::warning().
00133 { 00134 warning (false, "getArrayValue", "This node is not an array."); 00135 return false; 00136 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 124 of file form_elm.cpp. References uint, uint16, and NLGEORGES::CFormElm::warning().
00125 { 00126 warning (false, "getArrayValue", "This node is not an array."); 00127 return false; 00128 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 116 of file form_elm.cpp. References sint16, uint, and NLGEORGES::CFormElm::warning().
00117 { 00118 warning (false, "getArrayValue", "This node is not an array."); 00119 return false; 00120 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 108 of file form_elm.cpp. References uint, uint8, and NLGEORGES::CFormElm::warning().
00109 { 00110 warning (false, "getArrayValue", "This node is not an array."); 00111 return false; 00112 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 100 of file form_elm.cpp. References sint8, uint, and NLGEORGES::CFormElm::warning().
00101 { 00102 warning (false, "getArrayValue", "This node is not an array."); 00103 return false; 00104 } |
|
Get an array value. The node must be an array of atom element.
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 92 of file form_elm.cpp. References uint, and NLGEORGES::CFormElm::warning().
00093 { 00094 warning (false, "getArrayNode", "This node is not an array."); 00095 return false; 00096 } |
|
Implements NLGEORGES::CFormElm. Definition at line 2116 of file form_elm.cpp. References NLGEORGES::CFormElmStruct::FormDfn, and uint. Referenced by NLGEORGES::CForm::getDependencies().
|
|
Get the dfn filename for this virtual struct. Must be a virtual struct node.
Reimplemented from NLGEORGES::CFormElm. Definition at line 2215 of file form_elm.cpp. References DfnFilename.
02216 { 02217 dfnName = DfnFilename; 02218 return true; 02219 } |
|
Definition at line 353 of file form_elm.cpp. References NLGEORGES::CFormElm::Form. Referenced by NLGEORGES::CFormElm::warning().
00354 { 00355 return Form; 00356 } |
|
Implements NLGEORGES::CFormElm. Definition at line 2059 of file form_elm.cpp. References NLGEORGES::CFormElm::getFormName(), uint, and NLGEORGES::CFormElmStruct::warning(). Referenced by NLGEORGES::CFormElm::getIternalNodeByName(), warning(), and NLGEORGES::CFormElmStruct::warning().
02060 { 02061 // Reset the result 02062 if (child == NULL) 02063 { 02064 result = ""; 02065 result.reserve (50); 02066 } 02067 02068 // Get parent form name 02069 if (ParentNode) 02070 ParentNode->getFormName (result, this); 02071 02072 // Get node name 02073 if (child) 02074 { 02075 // Look for the child 02076 uint i; 02077 for (i=0; i<Elements.size (); i++) 02078 { 02079 // This one ? 02080 if (Elements[i].Element == child) 02081 { 02082 // Add the field name 02083 result += "."; 02084 result += Elements[i].Name; 02085 break; 02086 } 02087 } 02088 02089 // Draw some warning 02090 if (i==Elements.size ()) 02091 { 02092 warning (false, "getFormName", "Child node not found."); 02093 } 02094 } 02095 } |
|
Is createNode == Create, (*node)->Form must be == to the form argument. Is createNode == Return, form argument is not used, can be undefined. Only form, name, and action, must be defined. Then, else (*parentDfn / indexDfn ) or *node must be defined. Others value are for result only. Definition at line 764 of file form_elm.cpp. References NLGEORGES::CFormElmStruct::build(), NLGEORGES::CFormElm::Create, NLGEORGES::CFormElm::Delete, DfnFilename, NLGEORGES::CFormElmArray::Elements, NLGEORGES::CFormElmStruct::Elements, NLGEORGES::CFormDfn::Entries, NLGEORGES::CFormElmStruct::FormDfn, NLGEORGES::CFormDfn::CEntry::getArrayFlag(), NLGEORGES::CFormDfn::CEntry::getDfnPtr(), NLGEORGES::CFormDfn::getEntry(), NLGEORGES::CForm::getFilename(), NLGEORGES::CFormElm::getFormName(), NLGEORGES::CFormElmStruct::getFormName(), NLGEORGES::UFormElm::getNodeByName(), NLGEORGES::CForm::getParent(), NLGEORGES::CForm::getParentCount(), NLGEORGES::CForm::getRootNode(), NLGEORGES::CFormDfn::CEntry::getType(), NLGEORGES::CFormDfn::CEntry::getTypePtr(), NLGEORGES::CFormElm::isArray(), NLGEORGES::UFormElm::isVirtualStruct(), nlassert, NLGEORGES_MAX_RECURSION, nlstop, nlverify, NLGEORGES::CFormElm::Return, NLMISC::smprintf(), NLGEORGES::CFormElm::TokenArrayBegin, NLGEORGES::CFormElm::TokenArrayEnd, NLGEORGES::CFormElm::tokenize(), NLGEORGES::CFormElm::TokenPoint, NLGEORGES::CFormElm::TokenString, NLGEORGES::CType::Type, type, uint, uint32, NLGEORGES::CFormElm::unlink(), and NLGEORGES::CFormElm::warning(). Referenced by NLGEORGES::CFormElm::arrayDeleteNodeByName(), NLGEORGES::CFormElm::arrayInsertNodeByName(), NLGEORGES::CFormElm::createNodeByName(), NLGEORGES::CFormElm::deleteNodeByName(), and NLGEORGES::CFormElm::getNodeByName().
00765 { 00766 // *** Init output variables 00767 created = false; 00768 parentVDfnArray = false; 00769 00770 // ParentDfn or Node.. 00771 nlassert ( (*parentDfn) || (*node) ); 00772 00773 // Error message 00774 char error[512]; 00775 00776 // Parent exist ? 00777 if (*parentDfn) 00778 { 00779 // Get the entry 00780 const CFormDfn::CEntry &theEntry = (*parentDfn)->getEntry (indexDfn); 00781 00782 // Get the type 00783 type = theEntry.getType (); 00784 *nodeType = theEntry.getTypePtr (); 00785 if (type == UFormDfn::EntryVirtualDfn) 00786 { 00787 if (*node) 00788 *nodeDfn = safe_cast <CFormElmVirtualStruct*> (*node)->FormDfn; 00789 else 00790 *nodeDfn = NULL; 00791 } 00792 else 00793 *nodeDfn = theEntry.getDfnPtr (); 00794 array = theEntry.getArrayFlag (); 00795 } 00796 else if (*node) 00797 { 00798 nlassert (!(*node)->isArray ()); 00799 indexDfn = 0xffffffff; 00800 *nodeType = (*node)->isAtom () ? safe_cast<CFormElmAtom*>(*node)->Type : NULL; 00801 *nodeDfn = (*node)->isStruct () ? (const CFormDfn *)(safe_cast<CFormElmStruct*>(*node)->FormDfn) : NULL; 00802 type = (*node)->isAtom () ? UFormDfn::EntryType : (*node)->isVirtualStruct () ? UFormDfn::EntryVirtualDfn : UFormDfn::EntryDfn; 00803 array = false; 00804 } 00805 00806 // Check node pointer 00807 if (action == Create) 00808 { 00809 nlassert (*node); 00810 nlassert ((*node)->getForm () == form); 00811 } 00812 00813 // Backup current node 00814 CFormElm *backupFirstElm = *node; 00815 00816 // *** Parsing variables 00817 00818 // Current token start and end 00819 const char *startToken = name; 00820 const char *endToken; 00821 00822 // Current token start 00823 string token; 00824 00825 // Current form name 00826 string currentName; 00827 if (*node) 00828 (*node)->getFormName (currentName); 00829 00830 // Error 00831 uint errorIndex; 00832 00833 // Token code 00834 uint code; 00835 00836 // Are we parsing an array ? 00837 bool inArrayIndex = false; 00838 00839 // Index in the array 00840 uint arrayIndex; 00841 00842 // Bool next token must be an array index 00843 bool wantArrayIndex = false; 00844 00845 // Last struct elm 00846 CFormElmStruct *lastStructElm = ((*node)->ParentNode && (*node)->ParentNode->isStruct ()) ? safe_cast<CFormElmStruct*> ((*node)->ParentNode) : NULL; 00847 uint lastStructIndex = 0; 00848 if (lastStructElm) 00849 { 00850 // Look for node in the parent 00851 for (; lastStructIndex<lastStructElm->Elements.size (); lastStructIndex++) 00852 { 00853 // The same node ? 00854 if (lastStructElm->Elements[lastStructIndex].Element == (*node)) 00855 break; 00856 } 00857 00858 // Must have been found 00859 nlassert (lastStructIndex<lastStructElm->Elements.size ()); 00860 } 00861 00862 // While there is tokens 00863 while ((endToken = tokenize (startToken, token, errorIndex, code))) 00864 { 00865 // Ready an array index ? 00866 if (!inArrayIndex) 00867 { 00868 // For each code 00869 switch (code) 00870 { 00871 case TokenString: 00872 { 00873 // Need an array index array ? 00874 if (wantArrayIndex) 00875 { 00876 // Error message 00877 smprintf (error, 512, "Token (%s) should be an array index.", token.c_str()); 00878 goto exit; 00879 } 00880 00881 // Are we a struct ? 00882 if ( ((type == UFormDfn::EntryDfn) || (type == UFormDfn::EntryVirtualDfn)) /*&& (!array)*/ ) 00883 { 00884 // Check the virtual DFN is not empty.. 00885 if ( (type == UFormDfn::EntryVirtualDfn) && (*nodeDfn == NULL) ) 00886 { 00887 // Is it a parent virtual DFN ? 00888 if ( (type == UFormDfn::EntryVirtualDfn) && (*node == NULL) ) 00889 parentVDfnArray = true; 00890 00891 // Create mode ? 00892 if (action == Create) 00893 { 00894 // Should have a valid node 00895 nlassert (*node && lastStructElm); 00896 00897 // Get the current virtual dfn 00898 CFormElmVirtualStruct *vStruct = safe_cast<CFormElmVirtualStruct*> (*node); 00899 00900 // Get the form name of the current node 00901 string formName; 00902 vStruct->getFormName (formName, NULL); 00903 00904 // Get the parent node if available 00905 for (uint parent=0; parent<form->getParentCount (); parent++) 00906 { 00907 // Get the parent 00908 CForm *parentPtr = form->getParent (parent); 00909 nlassert (parentPtr); 00910 00911 // Get the virtual node by name 00912 UFormElm *uelm; 00913 if (parentPtr->getRootNode ().getNodeByName (&uelm, formName.c_str (), NULL, verbose, round+1) && uelm) 00914 { 00915 // Value node ? 00916 if (uelm->isVirtualStruct ()) 00917 { 00918 // Get a virtual struct pointer 00919 CFormElmVirtualStruct *vStructParent = safe_cast<CFormElmVirtualStruct*> (uelm); 00920 00921 // Copy the DFN filename 00922 vStruct->DfnFilename = vStructParent->DfnFilename; 00923 00924 // Build it 00925 vStruct->build (vStructParent->FormDfn); 00926 00927 // Set the current DFN 00928 *nodeDfn = vStruct->FormDfn; 00929 00930 // Stop looking for parent 00931 break; 00932 } 00933 else 00934 { 00935 // Error message 00936 smprintf (error, 512, "Internal node parsing error."); 00937 goto exit; 00938 } 00939 } 00940 } 00941 } 00942 00943 // Still no DFN ? 00944 if (*nodeDfn == NULL) 00945 { 00946 // Error message 00947 smprintf (error, 512, "Empty virtual struct element. Can't look into it while it is not defined."); 00948 goto exit; 00949 } 00950 } 00951 00952 // Must hjave a nodeDfn here 00953 nlassert (*nodeDfn); 00954 00955 // Look for the element 00956 // uint elementCount = (*nodeDfn)->getNumEntry (); 00957 00958 // Get the parents 00959 vector<const CFormDfn*> arrayDfn; 00960 arrayDfn.reserve ((*nodeDfn)->countParentDfn ()); 00961 (*nodeDfn)->getParentDfn (arrayDfn); 00962 00963 // For each parent 00964 uint i; 00965 uint formElm = 0; 00966 for (i=0; i<arrayDfn.size(); i++) 00967 { 00968 // The dfn 00969 const CFormDfn &dfn = *(arrayDfn[i]); 00970 00971 // For each elements 00972 uint element; 00973 for (element=0; element<dfn.Entries.size(); element++) 00974 { 00975 // Good name ? 00976 if (dfn.Entries[element].Name == token) 00977 { 00978 // Good one. 00979 *parentDfn = &dfn; 00980 indexDfn = element; 00981 *nodeDfn = dfn.Entries[element].Dfn; 00982 *nodeType = dfn.Entries[element].Type; 00983 type = dfn.Entries[element].TypeElement; 00984 array = dfn.Entries[element].Array; 00985 wantArrayIndex = array; 00986 00987 // Next node 00988 if (*node) 00989 { 00990 // Get next node 00991 CFormElmStruct *nodeStruct = safe_cast<CFormElmStruct*> (*node); 00992 CFormElm *nextElt = nodeStruct->Elements[formElm].Element; 00993 00994 // If no next node, watch for parent node 00995 *node = nextElt; 00996 00997 // Create node 00998 if ( (action == Create) && (*node == NULL) ) 00999 { 01000 // Is an array ? 01001 if (array) 01002 { 01003 // Create an atom 01004 CFormElmArray *atom = new CFormElmArray (form, *nodeDfn, *nodeType, nodeStruct, *parentDfn, indexDfn); 01005 *node = atom; 01006 } 01007 else 01008 { 01009 // What kind of node ? 01010 switch (type) 01011 { 01012 case UFormDfn::EntryType: 01013 { 01014 // Create an atom 01015 CFormElmAtom *atom = new CFormElmAtom (form, nodeStruct, *parentDfn, indexDfn); 01016 *node = atom; 01017 } 01018 break; 01019 case UFormDfn::EntryDfn: 01020 { 01021 CFormElmStruct *_struct = new CFormElmStruct (form, nodeStruct, *parentDfn, indexDfn); 01022 _struct->build (*nodeDfn); 01023 *node = _struct; 01024 } 01025 break; 01026 case UFormDfn::EntryVirtualDfn: 01027 *node = new CFormElmVirtualStruct (form, nodeStruct, *parentDfn, indexDfn); 01028 break; 01029 default: 01030 nlstop; 01031 } 01032 } 01033 01034 // Node created 01035 created = true; 01036 01037 // Set the node in parent 01038 nodeStruct->Elements[formElm].Element = *node; 01039 } 01040 01041 // Is a virtual DFN ? 01042 if ((*node) && (*node)->isVirtualStruct ()) 01043 { 01044 // Should be NULL 01045 nlassert (*nodeDfn == NULL); 01046 01047 // Set the current dfn 01048 *nodeDfn = safe_cast<const CFormElmVirtualStruct*> (*node)->FormDfn; 01049 } 01050 01051 // Save last struct 01052 lastStructElm = nodeStruct; 01053 lastStructIndex = formElm; 01054 } 01055 else 01056 { 01057 // Save last struct 01058 // CFormElmStruct *lastStructElm = NULL; 01059 //uint lastStructIndex = 0xffffffff; 01060 01061 *node = NULL; 01062 } 01063 01064 break; 01065 } 01066 formElm++; 01067 } 01068 01069 // Breaked ? 01070 if (element!=dfn.Entries.size()) 01071 break; 01072 } 01073 01074 // Breaked ? 01075 if (i==arrayDfn.size()) 01076 { 01077 // Not found 01078 smprintf (error, 512, "Struct does not contain element named (%s).", token.c_str()); 01079 goto exit; 01080 } 01081 } 01082 else 01083 { 01084 // Error message 01085 smprintf (error, 512, "Not a struct element. Can't open the node (%s).", token.c_str()); 01086 goto exit; 01087 } 01088 } 01089 break; 01090 case TokenPoint: 01091 { 01092 // Need an array index array ? 01093 if (wantArrayIndex) 01094 { 01095 // Error message 01096 smprintf (error, 512, "Token (%s) should be an array index.", token.c_str()); 01097 goto exit; 01098 } 01099 01100 // Are we a struct ? 01101 if ((type != UFormDfn::EntryDfn) && (type != UFormDfn::EntryVirtualDfn)) 01102 { 01103 // Error message 01104 smprintf (error, 512, "Not a struct element. Can't open the node (%s).", token.c_str()); 01105 goto exit; 01106 } 01107 } 01108 break; 01109 case TokenArrayBegin: 01110 { 01111 // Are we an array ? 01112 if (!array) 01113 { 01114 // Error message 01115 smprintf (error, 512, "Not an array element. Can't open the node (%s).", token.c_str()); 01116 goto exit; 01117 } 01118 inArrayIndex = true; 01119 arrayIndex = 0xffffffff; 01120 } 01121 break; 01122 default: 01123 { 01124 // Error message 01125 smprintf (error, 512, "Syntax error at keyword (%s).", token.c_str ()); 01126 goto exit; 01127 } 01128 break; 01129 } 01130 } 01131 else 01132 { 01133 switch (code) 01134 { 01135 case TokenString: 01136 { 01137 // To int 01138 if (sscanf (token.c_str(), "%d", &arrayIndex)!=1) 01139 { 01140 // Error message 01141 smprintf (error, 512, "Keyword (%s) is not an array index.", token.c_str()); 01142 goto exit; 01143 } 01144 01145 // Is it a parent virtual DFN ? 01146 if (*node == NULL) 01147 parentVDfnArray = true; 01148 01149 // Should have an array defined 01150 if (*node) 01151 { 01152 // Check index 01153 uint arraySize; 01154 nlverify ((*node)->getArraySize (arraySize)); 01155 if (arrayIndex>=arraySize) 01156 { 01157 // Create mode ? 01158 if (action == Create) 01159 { 01160 // Must be in the same form 01161 nlassert ((*node)->Form == form); 01162 01163 // The array pointer 01164 CFormElmArray *array = safe_cast<CFormElmArray*>(*node); 01165 uint oldSize = array->Elements.size (); 01166 array->Elements.resize (arrayIndex+1); 01167 01168 // Insert empty element 01169 uint i; 01170 for (i=oldSize; i<array->Elements.size (); i++) 01171 { 01172 // The new element 01173 CFormElm *newelm = NULL; 01174 switch (type) 01175 { 01176 case UFormDfn::EntryType: 01177 { 01178 // Create an atom 01179 CFormElmAtom *atom = new CFormElmAtom (form, array, *parentDfn, indexDfn); 01180 newelm = atom; 01181 } 01182 break; 01183 case UFormDfn::EntryDfn: 01184 { 01185 CFormElmStruct *_struct = new CFormElmStruct (form, array, *parentDfn, indexDfn); 01186 _struct->build (*nodeDfn); 01187 newelm = _struct; 01188 } 01189 break; 01190 case UFormDfn::EntryVirtualDfn: 01191 // todo array of virtual struct 01192 //newelm = new CFormElmVirtualStruct (form, array, *parentDfn, indexDfn); 01193 break; 01194 default: 01195 nlstop; 01196 } 01197 01198 nlassert (newelm); 01199 01200 // Node created 01201 created = true; 01202 01203 // Set the element pointer 01204 array->Elements[i].Element = newelm; 01205 } 01206 } 01207 else 01208 { 01209 // Error message 01210 smprintf (error, 512, "Out of array bounds (%d >= %d).", arrayIndex, arraySize); 01211 goto exit; 01212 } 01213 } 01214 } 01215 else 01216 { 01217 // Error message 01218 smprintf (error, 512, "Array is not defined."); 01219 goto exit; 01220 } 01221 } 01222 break; 01223 case TokenArrayEnd: 01224 { 01225 // No need of an array index any more 01226 wantArrayIndex = false; 01227 01228 // Index found ? 01229 if (arrayIndex == 0xffffffff) 01230 { 01231 // Error message 01232 smprintf (error, 512, "Missing array index."); 01233 } 01234 else 01235 { 01236 // Let the parent DFN 01237 nlassert (*parentDfn); 01238 01239 // New current node 01240 CFormElmArray *parentNode = safe_cast<CFormElmArray*> (*node); 01241 01242 // Get the element 01243 *node = parentNode->Elements[arrayIndex].Element; 01244 01245 // Is a dfn ? 01246 *nodeDfn = (*parentDfn)->getEntry (indexDfn).getDfnPtr (); 01247 01248 // Is a type ? 01249 *nodeType = (*parentDfn)->getEntry (indexDfn).getTypePtr (); 01250 01251 // Type ? 01252 type = (*parentDfn)->getEntry (indexDfn).getType (); 01253 01254 // Can't be an array of array 01255 array = false; 01256 01257 // Not any more in index 01258 inArrayIndex = false; 01259 01260 // What kind of node ? 01261 if ( (action == Create) && ( *node == NULL) ) 01262 { 01263 switch (type) 01264 { 01265 case UFormDfn::EntryType: 01266 { 01267 // Create an atom 01268 CFormElmAtom *atom = new CFormElmAtom (form, parentNode, *parentDfn, indexDfn); 01269 *node = atom; 01270 } 01271 break; 01272 case UFormDfn::EntryDfn: 01273 { 01274 CFormElmStruct *_struct = new CFormElmStruct (form, parentNode, *parentDfn, indexDfn); 01275 _struct->build (*nodeDfn); 01276 *node = _struct; 01277 } 01278 break; 01279 case UFormDfn::EntryVirtualDfn: 01280 // todo array of virtual struct 01281 // *node = new CFormElmVirtualStruct (form, parentNode, *parentDfn, indexDfn); 01282 break; 01283 default: 01284 nlstop; 01285 } 01286 01287 nlassert (*node); 01288 01289 // Node created 01290 created = true; 01291 01292 // Set the element pointer 01293 parentNode->Elements[arrayIndex].Element = *node; 01294 } 01295 01296 // Is a virtual DFN ? 01297 if ((*node) && (*node)->isVirtualStruct ()) 01298 { 01299 // Should be NULL 01300 nlassert (*nodeDfn == NULL); 01301 01302 // Set the current dfn 01303 *nodeDfn = safe_cast<const CFormElmVirtualStruct*> (*node)->FormDfn; 01304 } 01305 } 01306 } 01307 break; 01308 default: 01309 { 01310 // Error message 01311 smprintf (error, 512, "Keyword (%s) is not an array index.", token.c_str()); 01312 goto exit; 01313 } 01314 } 01315 } 01316 01317 // Concat current adress 01318 currentName += token; 01319 startToken = endToken; 01320 } 01321 exit:; 01322 01323 // Error ? 01324 bool errorAppend = endToken != NULL; 01325 01326 // Continue ? 01327 if (!errorAppend) 01328 { 01329 // Delete the node ? 01330 if ( (action == Delete) && (*node) ) 01331 { 01332 // Get its parent 01333 CFormElm *parent = safe_cast<CFormElm*> ((*node)->getParent ()); 01334 01335 // Don't erase the root structure 01336 if (parent && !parent->isArray ()) 01337 { 01338 // Unlink the primitive from its parent 01339 parent->unlink (*node); 01340 01341 // Erase the node 01342 delete (*node); 01343 *node = parent; 01344 parent = (CFormElm*) (parent->getParent ()); 01345 01346 // For each parent 01347 while (parent && !(*node)->isUsed (form) && !parent->isArray ()) 01348 { 01349 // Unlink the primitive from its parent 01350 parent->unlink (*node); 01351 01352 // Erase it and get next parent 01353 delete (*node); 01354 *node = parent; 01355 parent = (CFormElm*) (parent->getParent ()); 01356 } 01357 01358 // No more node 01359 *node = NULL; 01360 } 01361 } 01362 } 01363 01364 // Node not found in get node ? Look in parents ! 01365 if ( ((*node) == NULL) && (action == Return) && backupFirstElm ) 01366 { 01367 // Get the path name 01368 string formName; 01369 backupFirstElm->getFormName (formName); 01370 uint formNameSize = formName.size (); 01371 if ((formNameSize > 0) && (formName[formNameSize-1] != '.') && (formName[formNameSize-1] != '[')) 01372 formName += "."; 01373 formName += name; 01374 01375 // Backup first parent default value 01376 bool defaultValue = false; 01377 const CFormDfn *defaultParentDfnParent=0; 01378 uint defaultIndexDfnParent=0; 01379 const CFormDfn *defaultNodeDfnParent=0; 01380 const CType *defaultNodeTypeParent=0; 01381 CFormElm *defaultNodeParent=0; 01382 UFormDfn::TEntryType defaultTypeParent = UFormDfn::EntryType; 01383 bool defaultArrayParent=false; 01384 bool defaultCreatedParent=false; 01385 bool defaultParentVDfnArray=false; 01386 01387 // Look in parent form 01388 for (uint parent=0; parent<form->getParentCount (); parent++) 01389 { 01390 // Get the parent 01391 CForm *parentPtr = form->getParent (parent); 01392 nlassert (parentPtr); 01393 01394 // Get the node by name in the parent 01395 const CFormDfn *parentDfnParent = NULL; 01396 uint indexDfnParent = 0xffffffff; 01397 const CFormDfn *nodeDfnParent = NULL; 01398 const CType *nodeTypeParent = NULL; 01399 CFormElm *nodeParent = (CFormElm*)&parentPtr->getRootNode (); 01400 UFormDfn::TEntryType typeParent; 01401 bool arrayParent; 01402 bool createdParent; 01403 bool parentVDfnArray; 01404 if (getIternalNodeByName (parentPtr, formName.c_str (), &parentDfnParent, indexDfnParent, &nodeDfnParent, &nodeTypeParent, &nodeParent, typeParent, arrayParent, action, createdParent, parentVDfnArray, false, round+1)) 01405 { 01406 // Node found ? 01407 if (nodeParent) 01408 { 01409 // Found copy return values 01410 *parentDfn = parentDfnParent; 01411 indexDfn = indexDfnParent; 01412 *nodeDfn = nodeDfnParent; 01413 *nodeType = nodeTypeParent; 01414 *node = nodeParent; 01415 type = typeParent; 01416 array = arrayParent; 01417 created = createdParent; 01418 01419 return true; 01420 } 01421 else 01422 { 01423 // Backup the first parent default value found 01424 if (!defaultValue) 01425 { 01426 defaultParentDfnParent = parentDfnParent; 01427 defaultIndexDfnParent = indexDfnParent; 01428 defaultNodeDfnParent = nodeDfnParent; 01429 defaultNodeTypeParent = nodeTypeParent; 01430 defaultNodeParent = nodeParent; 01431 defaultTypeParent = typeParent; 01432 defaultArrayParent = arrayParent; 01433 defaultCreatedParent = createdParent; 01434 defaultParentVDfnArray = parentVDfnArray; 01435 defaultValue = true; 01436 } 01437 } 01438 } 01439 } 01440 01441 // Default value available ? 01442 if (defaultValue) 01443 { 01444 *parentDfn = defaultParentDfnParent; 01445 indexDfn = defaultIndexDfnParent; 01446 *nodeDfn = defaultNodeDfnParent; 01447 *nodeType = defaultNodeTypeParent; 01448 *node = defaultNodeParent; 01449 type = defaultTypeParent; 01450 array = defaultArrayParent; 01451 created = defaultCreatedParent; 01452 return true; 01453 } 01454 } 01455 01456 // Recurce warning ! 01457 if (*node) 01458 { 01459 if (round > NLGEORGES_MAX_RECURSION) 01460 { 01461 // Turn around.. 01462 string formName; 01463 (*node)->getFormName (formName); 01464 warning (false, formName.c_str (), form->getFilename ().c_str(), "getIternalNodeByName", "Recurcive call on the same node (%s), look for loop references or inheritances.", name); 01465 return false; 01466 } 01467 } 01468 01469 if (verbose && errorAppend) 01470 { 01471 nlassert (*error); 01472 01473 // Get the best form name 01474 warning (false, currentName.c_str (), form->getFilename ().c_str(), "getIternalNodeByName", "Getting the node (%s) : %s", name, error); 01475 } 01476 01477 return !errorAppend; 01478 } |
|
Definition at line 629 of file form_elm.cpp. References NLGEORGES::CFormElm::Form, NLGEORGES::CFormElm::getIternalNodeByName(), NLGEORGES::CFormElm::ParentDfn, NLGEORGES::CFormElm::ParentIndex, NLGEORGES::CFormElm::Return, type, uint, and uint32.
00633 { 00634 *parentDfn = ParentDfn; 00635 indexDfn = ParentIndex; 00636 *nodeDfn = NULL; 00637 *nodeType = NULL; 00638 *node = (CFormElm*)this; 00639 bool created; 00640 return getIternalNodeByName (Form, name, parentDfn, indexDfn, nodeDfn, nodeType, node, type, array, Return, created, parentVDfnArray, verbose, round); 00641 } |
|
Implements NLGEORGES::UFormElm. Definition at line 360 of file form_elm.cpp. References uint32.
00361 { 00362 const UFormElm *resultConst = NULL; 00363 if (((const UFormElm*)this)->getNodeByName (&resultConst, name, where, verbose, round)) 00364 { 00365 *result = const_cast<UFormElm*> (resultConst); 00366 return true; 00367 } 00368 return false; 00369 } |
|
Return a node pointer with its name.
An atom node exist if its value are defined. A struct node exist if one of its children exist. An array node exist if one of its children exist. If the node doesn't exist, you can't have a pointer on it with getNodeByName(). It returns NULL. But, you can evaluate the value of non-existant atom nodes with getValueByName(). About the form name: Struct elements name must be separeted by '.' Struct indexes must be between '[' and ']' Exemple: "position.x" : get the element named x in the struct named position "entities[2].color" : get the node named color in the second element of the entities array Implements NLGEORGES::UFormElm. Definition at line 373 of file form_elm.cpp. References NLGEORGES::CFormElm::Form, type, uint, and uint32. Referenced by NLGEORGES::CFormElm::getValueByName().
00374 { 00375 // The parent Dfn 00376 const CFormDfn *parentDfn; 00377 const CFormDfn *nodeDfn; 00378 const CType *nodeType; 00379 CFormElm *node; 00380 uint indexDfn; 00381 bool array; 00382 bool parentVDfnArray; 00383 UFormDfn::TEntryType type; 00384 00385 // Search for the node 00386 if (getNodeByName (name, &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, verbose, round)) 00387 { 00388 // Set the result 00389 *result = node; 00390 00391 // Where ? 00392 if (where && node) 00393 { 00394 *where = (node->getForm () == Form) ? NodeForm : NodeParentForm; 00395 } 00396 00397 // Ok 00398 return true; 00399 } 00400 00401 return false; 00402 } |
|
Definition at line 589 of file form_elm.cpp. References NLGEORGES::CFormElm::ParentNode.
00590 { 00591 return ParentNode; 00592 } |
|
Return the struct dfn.
Reimplemented from NLGEORGES::CFormElm. Definition at line 1762 of file form_elm.cpp. References NLGEORGES::CFormElmStruct::FormDfn.
01763 { 01764 return (CFormDfn*)FormDfn; 01765 } |
|
Return a mutable element pointer. Can be NULL if the node doesn't exist.
Reimplemented from NLGEORGES::CFormElm. Definition at line 1769 of file form_elm.cpp. References uint, and NLGEORGES::CFormElmStruct::warning().
|
|
Return a const element pointer. Can be NULL if the node doesn't exist.
Reimplemented from NLGEORGES::CFormElm. Definition at line 1746 of file form_elm.cpp. References uint, and NLGEORGES::CFormElmStruct::warning().
|
|
Return the element name.
Reimplemented from NLGEORGES::CFormElm. Definition at line 1730 of file form_elm.cpp. References uint, and NLGEORGES::CFormElmStruct::warning().
|
|
Return the struct size.
Reimplemented from NLGEORGES::CFormElm. Definition at line 1722 of file form_elm.cpp.
|
|
Warning, only R, G and B members are filled, not A.
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 320 of file form_elm.cpp. References NLGEORGES::CFormElm::warning().
00321 { 00322 warning (false, "getValue", "This node is not an atom."); 00323 return false; 00324 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 312 of file form_elm.cpp. References NLGEORGES::CFormElm::warning().
00313 { 00314 warning (false, "getValue", "This node is not an atom."); 00315 return false; 00316 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 304 of file form_elm.cpp. References NLGEORGES::CFormElm::warning().
00305 { 00306 warning (false, "getValue", "This node is not an atom."); 00307 return false; 00308 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 296 of file form_elm.cpp. References NLGEORGES::CFormElm::warning().
00297 { 00298 warning (false, "getValue", "This node is not an atom."); 00299 return false; 00300 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 288 of file form_elm.cpp. References uint32, and NLGEORGES::CFormElm::warning().
00289 { 00290 warning (false, "getValue", "This node is not an atom."); 00291 return false; 00292 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 280 of file form_elm.cpp. References sint32, and NLGEORGES::CFormElm::warning().
00281 { 00282 warning (false, "getValue", "This node is not an atom."); 00283 return false; 00284 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 272 of file form_elm.cpp. References uint16, and NLGEORGES::CFormElm::warning().
00273 { 00274 warning (false, "getValue", "This node is not an atom."); 00275 return false; 00276 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 264 of file form_elm.cpp. References sint16, and NLGEORGES::CFormElm::warning().
00265 { 00266 warning (false, "getValue", "This node is not an atom."); 00267 return false; 00268 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 256 of file form_elm.cpp. References uint8, and NLGEORGES::CFormElm::warning().
00257 { 00258 warning (false, "getValue", "This node is not an atom."); 00259 return false; 00260 } |
|
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 248 of file form_elm.cpp. References sint8, and NLGEORGES::CFormElm::warning().
00249 { 00250 warning (false, "getValue", "This node is not an atom."); 00251 return false; 00252 } |
|
Return the atom value. The numbers are clamped to the type limit values.
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 240 of file form_elm.cpp. References NLGEORGES::CFormElm::warning().
00241 { 00242 warning (false, "getValue", "This node is not an atom."); 00243 return false; 00244 }; |
|
Warning, only R, G and B members are filled, not A.
Implements NLGEORGES::UFormElm. Definition at line 575 of file form_elm.cpp. References NLGEORGES::CFormElm::convertValue(), NLGEORGES::CFormElm::getValueByName(), uint32, and value.
00576 { 00577 // Get the string value 00578 string value; 00579 if (getValueByName (value, name, evaluate, where, round)) 00580 { 00581 return convertValue (result, value.c_str ()); 00582 } 00583 00584 return false; 00585 } |
|
Implements NLGEORGES::UFormElm. Definition at line 561 of file form_elm.cpp. References NLGEORGES::CFormElm::convertValue(), NLGEORGES::CFormElm::getValueByName(), uint32, and value.
00562 { 00563 // Get the string value 00564 string value; 00565 if (getValueByName (value, name, evaluate, where, round)) 00566 { 00567 return convertValue (result, value.c_str ()); 00568 } 00569 00570 return false; 00571 } |
|
Implements NLGEORGES::UFormElm. Definition at line 547 of file form_elm.cpp. References NLGEORGES::CFormElm::convertValue(), NLGEORGES::CFormElm::getValueByName(), uint32, and value.
00548 { 00549 // Get the string value 00550 string value; 00551 if (getValueByName (value, name, evaluate, where, round)) 00552 { 00553 return convertValue (result, value.c_str ()); 00554 } 00555 00556 return false; 00557 } |
|
Implements NLGEORGES::UFormElm. Definition at line 533 of file form_elm.cpp. References NLGEORGES::CFormElm::convertValue(), NLGEORGES::CFormElm::getValueByName(), uint32, and value.
00534 { 00535 // Get the string value 00536 string value; 00537 if (getValueByName (value, name, evaluate, where, round)) 00538 { 00539 return convertValue (result, value.c_str ()); 00540 } 00541 00542 return false; 00543 } |
|
Implements NLGEORGES::UFormElm. Definition at line 519 of file form_elm.cpp. References NLGEORGES::CFormElm::convertValue(), NLGEORGES::CFormElm::getValueByName(), uint32, and value.
00520 { 00521 // Get the string value 00522 string value; 00523 if (getValueByName (value, name, evaluate, where, round)) 00524 { 00525 return convertValue (result, value.c_str ()); 00526 } 00527 00528 return false; 00529 } |
|
Implements NLGEORGES::UFormElm. Definition at line 505 of file form_elm.cpp. References NLGEORGES::CFormElm::convertValue(), NLGEORGES::CFormElm::getValueByName(), sint32, uint32, and value.
00506 { 00507 // Get the string value 00508 string value; 00509 if (getValueByName (value, name, evaluate, where, round)) 00510 { 00511 return convertValue (result, value.c_str ()); 00512 } 00513 00514 return false; 00515 } |
|
Implements NLGEORGES::UFormElm. Definition at line 491 of file form_elm.cpp. References NLGEORGES::CFormElm::convertValue(), NLGEORGES::CFormElm::getValueByName(), uint16, uint32, and value.
00492 { 00493 // Get the string value 00494 string value; 00495 if (getValueByName (value, name, evaluate, where, round)) 00496 { 00497 return convertValue (result, value.c_str ()); 00498 } 00499 00500 return false; 00501 } |
|
Implements NLGEORGES::UFormElm. Definition at line 477 of file form_elm.cpp. References NLGEORGES::CFormElm::convertValue(), NLGEORGES::CFormElm::getValueByName(), sint16, uint32, and value.
00478 { 00479 // Get the string value 00480 string value; 00481 if (getValueByName (value, name, evaluate, where, round)) 00482 { 00483 return convertValue (result, value.c_str ()); 00484 } 00485 00486 return false; 00487 } |
|
Implements NLGEORGES::UFormElm. Definition at line 463 of file form_elm.cpp. References NLGEORGES::CFormElm::convertValue(), NLGEORGES::CFormElm::getValueByName(), uint32, uint8, and value.
00464 { 00465 // Get the string value 00466 string value; 00467 if (getValueByName (value, name, evaluate, where, round)) 00468 { 00469 return convertValue (result, value.c_str ()); 00470 } 00471 00472 return false; 00473 } |
|
Implements NLGEORGES::UFormElm. Definition at line 449 of file form_elm.cpp. References NLGEORGES::CFormElm::convertValue(), NLGEORGES::CFormElm::getValueByName(), sint8, uint32, and value.
00450 { 00451 // Get the string value 00452 string value; 00453 if (getValueByName (value, name, evaluate, where, round)) 00454 { 00455 return convertValue (result, value.c_str ()); 00456 } 00457 00458 return false; 00459 } |
|
Get a form value with its name. The numbers are clamped to the type limit values.
Implements NLGEORGES::UFormElm. Definition at line 406 of file form_elm.cpp. References NLGEORGES::CFormElm::Form, NLGEORGES::CFormElm::getNodeByName(), NLGEORGES::CType::getValue(), nlassert, type, uint, uint32, and NLGEORGES::CFormElm::warning(). Referenced by NLGEORGES::CFormElm::getValueByName().
00407 { 00408 // The parent Dfn 00409 const CFormDfn *parentDfn; 00410 const CFormDfn *nodeDfn; 00411 const CType *nodeType; 00412 CFormElm *node; 00413 uint parentIndex; 00414 bool array; 00415 bool parentVDfnArray; 00416 UFormDfn::TEntryType type; 00417 00418 // Search for the node 00419 if (getNodeByName (name, &parentDfn, parentIndex, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, round)) 00420 { 00421 // End, return the current index 00422 if (type == UFormDfn::EntryType) 00423 { 00424 // The atom 00425 const CFormElmAtom *atom = node ? safe_cast<const CFormElmAtom*> (node) : NULL; 00426 00427 // Evale 00428 nlassert (nodeType); 00429 return (nodeType->getValue (result, Form, atom, *parentDfn, parentIndex, evaluate, (uint32*)where, round, name)); 00430 } 00431 else 00432 { 00433 // Error message 00434 warning (false, "getValueByName", "The node (%s) is not an atom element. Can't return a value.", name); 00435 } 00436 } 00437 else 00438 { 00439 // Error message 00440 warning (false, "getValueByName", "Can't find the node (%s).", name); 00441 } 00442 00443 // Error 00444 return false; 00445 } |
|
Return true if the element is an array.
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmArray. Definition at line 53 of file form_elm.cpp. Referenced by NLGEORGES::CFormElm::arrayDeleteNodeByName(), NLGEORGES::CFormElm::arrayInsertNodeByName(), and NLGEORGES::CFormElm::getIternalNodeByName().
00054 { 00055 return false; 00056 }; |
|
Return true if the element is an atom.
Implements NLGEORGES::UFormElm. Reimplemented in NLGEORGES::CFormElmAtom. Definition at line 233 of file form_elm.cpp.
00234 { 00235 return false; 00236 }; |
|
Return true if the element is a struct or a virtual struct.
Reimplemented from NLGEORGES::CFormElm. Definition at line 1715 of file form_elm.cpp.
01716 { 01717 return true; 01718 }; |
|
Reimplemented from NLGEORGES::CFormElmStruct. Definition at line 2223 of file form_elm.cpp. Referenced by write().
02224 { 02225 return true; 02226 } |
|
Return true if the element is a virtual struct.
Reimplemented from NLGEORGES::CFormElm. Definition at line 2208 of file form_elm.cpp.
02209 { 02210 return true; 02211 } |
|
Definition at line 1817 of file form_elm.cpp. References NLGEORGES::CFormElmStruct::build(), NLGEORGES::CFormElmStruct::CFormElmStruct(), NLGEORGES::CFormDfn::countParentDfn(), NLGEORGES::CFormElmStruct::FormDfn, NLGEORGES::CFormDfn::getParentDfn(), nlassert, read(), NLGEORGES::CFormElmAtom::read(), NLGEORGES::CFormElmArray::read(), uint, and NLGEORGES::CFormElmStruct::warning(). Referenced by NLGEORGES::CFormElmArray::read(), and NLGEORGES::CForm::read().
01818 { 01819 // Get the smart pointer on the dfn 01820 FormDfn = (CFormDfn*)dfn; 01821 01822 // Build the Form 01823 build (dfn); 01824 01825 // Count parent 01826 uint dfnCount = dfn->countParentDfn (); 01827 01828 // Array of Dfn 01829 std::vector<const CFormDfn*> dfnArray; 01830 dfnArray.reserve (dfnCount); 01831 dfn->getParentDfn (dfnArray); 01832 01833 // For each Dfn 01834 uint dfnId; 01835 uint elmIndex=0; 01836 for (dfnId=0; dfnId<dfnCount; dfnId++) 01837 { 01838 // Lookup for the name in the DFN 01839 uint elm; 01840 for (elm=0; elm<dfnArray[dfnId]->Entries.size(); elm++) 01841 { 01842 // Found ? 01843 // bool found = false; 01844 01845 // Read the struct 01846 xmlNodePtr child = NULL; 01847 01848 // Node can be NULL 01849 if (node) 01850 child = node->children; 01851 01852 while (child) 01853 { 01854 // Good node ? 01855 const char *name = (const char*)xmlGetProp (child, (xmlChar*)"Name"); 01856 if (name && (dfnArray[dfnId]->Entries[elm].getName () == name) ) 01857 { 01858 // Type 01859 bool atom=false; 01860 bool array=false; 01861 bool _struct=false; 01862 bool vStruct=false; 01863 01864 // Is an atom ? 01865 if (strcmp ((const char*)child->name, "ATOM") == 0) 01866 { 01867 atom = true; 01868 } 01869 // Is a struct ? 01870 else if (strcmp ((const char*)child->name, "STRUCT") == 0) 01871 { 01872 _struct = true; 01873 } 01874 // Is a struct ? 01875 else if (strcmp ((const char*)child->name, "VSTRUCT") == 0) 01876 { 01877 vStruct = true; 01878 } 01879 // Is an array ? 01880 else if (strcmp ((const char*)child->name, "ARRAY") == 0) 01881 { 01882 array = true; 01883 } 01884 01885 // Continue ? 01886 if (atom || _struct || vStruct || array) 01887 { 01888 // Same type ? 01889 if ( 01890 (atom && (dfnArray[dfnId]->Entries[elm].getType ()==UFormDfn::EntryType) && (!dfnArray[dfnId]->Entries[elm].getArrayFlag ()) ) || 01891 (array && dfnArray[dfnId]->Entries[elm].getArrayFlag () && ( (dfnArray[dfnId]->Entries[elm].getType () == UFormDfn::EntryType) || (dfnArray[dfnId]->Entries[elm].getType () == UFormDfn::EntryDfn) ) ) || 01892 (_struct && (dfnArray[dfnId]->Entries[elm].getType () == UFormDfn::EntryDfn) && (!dfnArray[dfnId]->Entries[elm].getArrayFlag ()) ) || 01893 (vStruct && (dfnArray[dfnId]->Entries[elm].getType () == UFormDfn::EntryVirtualDfn) && (!dfnArray[dfnId]->Entries[elm].getArrayFlag ()) ) 01894 ) 01895 { 01896 // Ok keep it 01897 xmlFree((void*) name); 01898 break; 01899 } 01900 else 01901 { 01902 // Make a warning message 01903 warning (false, "read", "In block line %d, node (%s) type in DFN have changed.", 01904 (int)child->content, child->name); 01905 } 01906 } 01907 else 01908 { 01909 if (name) 01910 { 01911 // Delete the value 01912 xmlFree ((void*)name); 01913 } 01914 01915 // Throw exception 01916 warning (true, "read", "XML Syntax error in block line %d, node (%s) name should be STRUCT, ATOM or ARRAY.", 01917 (int)child->content, child->name); 01918 } 01919 } 01920 01921 if (name) 01922 { 01923 // Delete the value 01924 xmlFree ((void*)name); 01925 } 01926 01927 // Next child 01928 child = child->next; 01929 } 01930 01931 // Found ? 01932 if (child) 01933 { 01934 // Create a new element 01935 if (dfnArray[dfnId]->Entries[elm].getArrayFlag ()) 01936 { 01937 // Array of type 01938 CFormElmArray *newElm = NULL; 01939 if (dfnArray[dfnId]->Entries[elm].getType () == UFormDfn::EntryType) 01940 { 01941 // Load the new element 01942 newElm = new CFormElmArray (form, NULL, dfnArray[dfnId]->Entries[elm].getTypePtr (), this, dfnArray[dfnId], elm); 01943 } 01944 // Array of struct 01945 else if (dfnArray[dfnId]->Entries[elm].getType () == UFormDfn::EntryDfn) 01946 { 01947 newElm = new CFormElmArray (form, dfnArray[dfnId]->Entries[elm].getDfnPtr (), NULL, this, dfnArray[dfnId], elm); 01948 } 01949 01950 // Should be created 01951 nlassert (newElm); 01952 Elements[elmIndex].Element = newElm; 01953 newElm->read (child, loader, form); 01954 } 01955 else if (dfnArray[dfnId]->Entries[elm].getType () == UFormDfn::EntryType) 01956 { 01957 // Load the new element 01958 CFormElmAtom *newElm = new CFormElmAtom (form, this, dfnArray[dfnId], elm); 01959 Elements[elmIndex].Element = newElm; 01960 newElm->read (child, loader, dfnArray[dfnId]->Entries[elm].getTypePtr (), form); 01961 } 01962 else if (dfnArray[dfnId]->Entries[elm].getType () == UFormDfn::EntryDfn) 01963 { 01964 // Load the new element 01965 CFormElmStruct *newElm = new CFormElmStruct (form, this, dfnArray[dfnId], elm); 01966 Elements[elmIndex].Element = newElm; 01967 newElm->read (child, loader, dfnArray[dfnId]->Entries[elm].getDfnPtr (), form); 01968 } 01969 else // if dfnArray[dfnId]->Entries[elm].getType () == CFormDfn::CEntry::EntryVirtualDfn) 01970 { 01971 // Should be a struct 01972 nlassert (dfnArray[dfnId]->Entries[elm].getType () == UFormDfn::EntryVirtualDfn); 01973 01974 // Load the new element 01975 CFormElmVirtualStruct *newElm = new CFormElmVirtualStruct (form, this, dfnArray[dfnId], elm); 01976 Elements[elmIndex].Element = newElm; 01977 newElm->read (child, loader, form); 01978 } 01979 } 01980 else 01981 Elements[elmIndex].Element = NULL; 01982 01983 elmIndex++; 01984 } 01985 } 01986 } |
|
Definition at line 2175 of file form_elm.cpp. References DfnFilename, NLGEORGES::CFormLoader::loadFormDfn(), and warning(). Referenced by NLGEORGES::CFormElmStruct::read().
02176 { 02177 // Get the DFN filename 02178 const char *filename = (const char*)xmlGetProp (node, (xmlChar*)"DfnName"); 02179 if (filename) 02180 { 02181 // Set the name 02182 DfnFilename = filename; 02183 02184 // Delete the value 02185 xmlFree ((void*)filename); 02186 02187 // Load the dfn 02188 FormDfn = loader.loadFormDfn (DfnFilename.c_str (), false); 02189 if (!FormDfn) 02190 { 02191 // Throw exception 02192 warning (true, "read", "Can't find DFN filename (%s).", DfnFilename.c_str ()); 02193 } 02194 } 02195 else 02196 { 02197 // Throw exception 02198 warning (true, "read", "XML Syntax error in virtual struct in block line %d, should have a DfnName property.", 02199 (int)node->content, node->name); 02200 } 02201 02202 // Read the parent 02203 CFormElmStruct::read (node, loader, FormDfn, form); 02204 } |
|
Implements NLGEORGES::UFormElm. Definition at line 1647 of file form_elm.cpp. References NLGEORGES::CFormElm::setValueByName(), NLMISC::smprintf(), and value.
01648 { 01649 char tmp[512]; 01650 smprintf (tmp, 512, "%d,%d,%d", value.R, value.G, value.B); 01651 return setValueByName (tmp, name, created); 01652 } |
|
Implements NLGEORGES::UFormElm. Definition at line 1640 of file form_elm.cpp. References NLGEORGES::CFormElm::setValueByName(), NLMISC::toString(), and value.
01641 { 01642 return setValueByName (toString (value).c_str (), name, created); 01643 } |
|
Implements NLGEORGES::UFormElm. Definition at line 1633 of file form_elm.cpp. References NLGEORGES::CFormElm::setValueByName(), NLMISC::toString(), and value.
01634 { 01635 return setValueByName (toString (value).c_str (), name, created); 01636 } |
|
Implements NLGEORGES::UFormElm. Definition at line 1626 of file form_elm.cpp. References NLGEORGES::CFormElm::setValueByName(), NLMISC::toString(), and value.
01627 { 01628 return setValueByName (toString (value).c_str (), name, created); 01629 } |
|
Implements NLGEORGES::UFormElm. Definition at line 1619 of file form_elm.cpp. References NLGEORGES::CFormElm::setValueByName(), NLMISC::toString(), uint32, and value.
01620 { 01621 return setValueByName (toString (value).c_str (), name, created); 01622 } |
|
Implements NLGEORGES::UFormElm. Definition at line 1612 of file form_elm.cpp. References NLGEORGES::CFormElm::setValueByName(), sint32, NLMISC::toString(), and value.
01613 { 01614 return setValueByName (toString (value).c_str (), name, created); 01615 } |
|
Implements NLGEORGES::UFormElm. Definition at line 1605 of file form_elm.cpp. References NLGEORGES::CFormElm::setValueByName(), NLMISC::toString(), uint16, and value.
01606 { 01607 return setValueByName (toString (value).c_str (), name, created); 01608 } |
|
Implements NLGEORGES::UFormElm. Definition at line 1598 of file form_elm.cpp. References NLGEORGES::CFormElm::setValueByName(), sint16, NLMISC::toString(), and value.
01599 { 01600 return setValueByName (toString (value).c_str (), name, created); 01601 } |
|
Implements NLGEORGES::UFormElm. Definition at line 1591 of file form_elm.cpp. References NLGEORGES::CFormElm::setValueByName(), NLMISC::toString(), uint8, and value.
01592 { 01593 return setValueByName (toString (value).c_str (), name, created); 01594 } |
|
Implements NLGEORGES::UFormElm. Definition at line 1584 of file form_elm.cpp. References NLGEORGES::CFormElm::setValueByName(), sint8, NLMISC::toString(), and value.
01585 { 01586 return setValueByName (toString (value).c_str (), name, created); 01587 } |
|
Set a form value with its name. If the node doesn't exist, it is created.
Implements NLGEORGES::UFormElm. Definition at line 1532 of file form_elm.cpp. References NLGEORGES::CFormElm::createNodeByName(), nlassert, NLGEORGES::CFormElmAtom::setValue(), type, uint, value, and NLGEORGES::CFormElm::warning(). Referenced by NLGEORGES::CFormElm::setValueByName().
01533 { 01534 // The parent Dfn 01535 const CFormDfn *parentDfn; 01536 const CFormDfn *nodeDfn; 01537 const CType *nodeType; 01538 CFormElm *node; 01539 uint indexDfn; 01540 bool array; 01541 bool _created; 01542 UFormDfn::TEntryType type; 01543 01544 // Search for the node 01545 if (createNodeByName (name, &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, _created)) 01546 { 01547 // Is this a type ? 01548 if (type == UFormDfn::EntryType) 01549 { 01550 // The atom 01551 CFormElmAtom *atom = node ? safe_cast<CFormElmAtom*> (node) : NULL; 01552 01553 // Evale 01554 nlassert (nodeType); 01555 atom->setValue (value); 01556 01557 // Created flag 01558 if (created) 01559 *created = _created; 01560 return true; 01561 } 01562 else 01563 { 01564 // Error message 01565 warning (false, "setValueByName", "The node (%s) is not an atom element. Can't set the value.", name); 01566 } 01567 } 01568 else 01569 { 01570 // Error message 01571 warning (false, "setValueByName", "Can't created / set the node (%s).", name); 01572 01573 // Created flag 01574 if (created) 01575 *created = false; 01576 } 01577 01578 // Error 01579 return false; 01580 } |
|
Definition at line 1482 of file form_elm.cpp. References NLGEORGES::CFormElm::TokenArrayBegin, NLGEORGES::CFormElm::TokenArrayEnd, NLGEORGES::CFormElm::TokenPoint, NLGEORGES::CFormElm::TokenString, and uint. Referenced by NLGEORGES::CFormElm::getIternalNodeByName().
01483 { 01484 if (*name == 0) 01485 { 01486 return NULL; 01487 } 01488 01489 if (*name == '[') 01490 { 01491 code = TokenArrayBegin; 01492 str = "["; 01493 return name+1; 01494 } 01495 01496 if (*name == ']') 01497 { 01498 code = TokenArrayEnd; 01499 str = "]"; 01500 return name+1; 01501 } 01502 01503 if (*name == '.') 01504 { 01505 code = TokenPoint; 01506 str = "."; 01507 return name+1; 01508 } 01509 01510 str = ""; 01511 while ( (*name != '.') && (*name != '[') && (*name != ']') && (*name != 0) ) 01512 { 01513 // Add a char 01514 str += *name; 01515 name++; 01516 } 01517 01518 code = TokenString; 01519 return name; 01520 } |
|
Unlink a child Reimplemented from NLGEORGES::CFormElm. Definition at line 2041 of file form_elm.cpp. References nlassert, and uint.
|
|
Definition at line 1656 of file form_elm.cpp. References buffer, format, and NLGEORGES::warning(). Referenced by NLGEORGES::CFormElm::convertValue(), NLGEORGES::CFormElm::getArrayNode(), NLGEORGES::CFormElm::getArrayNodeName(), NLGEORGES::CFormElm::getArraySize(), NLGEORGES::CFormElm::getArrayValue(), NLGEORGES::CFormElm::getIternalNodeByName(), NLGEORGES::CFormElm::getStructNode(), NLGEORGES::CFormElm::getStructNodeName(), NLGEORGES::CFormElm::getStructSize(), NLGEORGES::CFormElm::getValue(), NLGEORGES::CFormElm::getValueByName(), NLGEORGES::CFormElm::setValueByName(), and NLGEORGES::CFormElm::warning().
01657 { 01658 // Make a buffer string 01659 va_list args; 01660 va_start( args, format ); 01661 char buffer[1024]; 01662 vsnprintf( buffer, 1024, format, args ); 01663 va_end( args ); 01664 01665 // Set the warning 01666 NLGEORGES::warning (exception, "(CFormElm::%s) on node (%s) in form (%s) : %s", function, formName, formFileName, buffer); 01667 } |
|
Reimplemented from NLGEORGES::CFormElmStruct. Definition at line 2230 of file form_elm.cpp. References buffer, format, NLGEORGES::CForm::getFilename(), NLGEORGES::CFormElmStruct::getFormName(), and NLGEORGES::warning(). Referenced by read().
02231 { 02232 // Make a buffer string 02233 va_list args; 02234 va_start( args, format ); 02235 char buffer[1024]; 02236 vsnprintf( buffer, 1024, format, args ); 02237 va_end( args ); 02238 02239 // Set the warning 02240 string formName; 02241 getFormName (formName, NULL); 02242 NLGEORGES::warning (exception, "(CFormElmVirtualStruct::%s) on node (%s) in form (%s) : %s", function, formName.c_str (), Form->getFilename ().c_str (), buffer); 02243 } |
|
Reimplemented from NLGEORGES::CFormElmStruct. Definition at line 2140 of file form_elm.cpp. References DfnFilename, isUsed(), and uint.
02141 { 02142 // Is used ? 02143 if (isUsed (form) || forceWrite) 02144 { 02145 // *** Header 02146 xmlNodePtr node = xmlNewChild ( root, NULL, (const xmlChar*)"VSTRUCT", NULL); 02147 02148 // Write the DFN filename in the node 02149 xmlSetProp (node, (const xmlChar*)"DfnName", (const xmlChar*)DfnFilename.c_str()); 02150 02151 // Element name 02152 if (structName != NULL) 02153 { 02154 // Struct name 02155 xmlSetProp (node, (const xmlChar*)"Name", (const xmlChar*)structName); 02156 } 02157 02158 // For each elements of the structure 02159 uint elm; 02160 for (elm=0; elm<Elements.size(); elm++) 02161 { 02162 // Create a node if it exist 02163 if (Elements[elm].Element) 02164 Elements[elm].Element->write (node, form, Elements[elm].Name.c_str()); 02165 } 02166 02167 // Return the new node 02168 return node; 02169 } 02170 return NULL; 02171 } |
|
Definition at line 335 of file form_elm.h. Referenced by getDfnName(), NLGEORGES::CFormElm::getIternalNodeByName(), read(), and write(). |
|
Definition at line 318 of file form_elm.h. Referenced by NLGEORGES::CFormElm::getIternalNodeByName(). |
|
|
|
|
|
Definition at line 234 of file form_elm.h. Referenced by NLGEORGES::CFormElm::CFormElm(), and NLGEORGES::CFormElm::getParent(). |
|
Definition at line 243 of file form_elm.h. |