NLGEORGES::CFormElm Class Reference

#include <form_elm.h>

Inheritance diagram for NLGEORGES::CFormElm:

NLGEORGES::UFormElm NLGEORGES::CFormElmArray NLGEORGES::CFormElmAtom NLGEORGES::CFormElmStruct NLGEORGES::CFormElmVirtualStruct

Detailed Description

Base class of form elments

Definition at line 48 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
 CFormElm (CForm *form, CFormElm *parentNode, const CFormDfn *parentDfn, uint parentIndex)
virtual 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
virtual void getDependencies (std::set< std::string > &dependencies) const=0
virtual bool getDfnName (std::string &dfnName) const
 Get the dfn filename for this virtual struct. Must be a virtual struct node.

CFormgetForm () const
virtual void getFormName (std::string &result, const CFormElm *child=NULL) const=0
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 UFormElmgetParent () const
virtual UFormDfngetStructDfn ()
 Return the struct dfn.

virtual bool getStructNode (uint element, UFormElm **result)
 Return a mutable element pointer. Can be NULL if the node doesn't exist.

virtual bool getStructNode (uint element, const UFormElm **result) const
 Return a const element pointer. Can be NULL if the node doesn't exist.

virtual bool getStructNodeName (uint element, std::string &result) const
 Return the element name.

virtual 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.

virtual bool isStruct () const
 Return true if the element is a struct or a virtual struct.

virtual bool isUsed (const CForm *form) const
virtual bool isVirtualStruct () const
 Return true if the element is a virtual struct.

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)
virtual xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName=NULL, bool forceWrite=false) const=0
virtual ~CFormElm ()

Static Public Member Functions

const char * tokenize (const char *name, std::string &str, uint &errorIndex, uint &code)

Protected Types

enum  TNodeAction { Return, Create, Delete }

Protected Member Functions

virtual void unlink (CFormElm *child)
virtual void warning (bool exception, const char *function, const char *format,...) const

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

CFormForm
const CFormDfnParentDfn
uint ParentIndex
CFormElmParentNode
uint32 Round

Private Types

enum  TToken { TokenString = 0, TokenPoint, TokenArrayBegin, TokenArrayEnd }

Friends

class CForm
class CFormDfn
class CType


Member Enumeration Documentation

enum NLGEORGES::UFormElm::TEval [inherited]
 

Value evalution.

Enumeration values:
NoEval 
Formula  The value will not be evaluated at all, the litteral value will be returned.
Eval  Eval the enumeration value, but don't evaluate the formula nor the value references.

Definition at line 47 of file u_form_elm.h.

00048         {               
00049                 NoEval,                         
00050                 Formula,                        
00051                 Eval,                           
00052         };

enum NLGEORGES::CFormElm::TNodeAction [protected]
 

Enumeration values:
Return 
Create 
Delete 

Definition at line 195 of file form_elm.h.

00196         {
00197                 Return,
00198                 Create,
00199                 Delete,
00200         };

enum NLGEORGES::CFormElm::TToken [private]
 

Enumeration values:
TokenString 
TokenPoint 
TokenArrayBegin 
TokenArrayEnd 

Definition at line 251 of file form_elm.h.

00252         {
00253                 TokenString = 0,
00254                 TokenPoint,
00255                 TokenArrayBegin,
00256                 TokenArrayEnd,
00257         };

enum NLGEORGES::UFormElm::TWhereIsNode [inherited]
 

Where a node has been found.

Enumeration values:
NodeForm 
NodeParentForm  The node has been found in the form.
NodeDfn  The node has been found in the parent form.
NodeType  The node is a DFN.

Definition at line 55 of file u_form_elm.h.

00056         {
00057                 NodeForm,                       
00058                 NodeParentForm,         
00059                 NodeDfn,                        
00060                 NodeType,                       
00061         };

enum NLGEORGES::UFormElm::TWhereIsValue [inherited]
 

Where a value has been found.

Enumeration values:
ValueForm 
ValueParentForm  The value has been found in the form.
ValueDefaultDfn  The value has been found in the parent form.
ValueDefaultType  The value has been found in the DFN default value.
Dummy  The value has been found in the TYPE default value.

Definition at line 94 of file u_form_elm.h.

00095         {
00096                 ValueForm,                              
00097                 ValueParentForm,                
00098                 ValueDefaultDfn,                
00099                 ValueDefaultType,               
00100                 Dummy = 0xffffffff              
00101         };


Constructor & Destructor Documentation

NLGEORGES::CFormElm::CFormElm CForm form,
CFormElm parentNode,
const CFormDfn parentDfn,
uint  parentIndex
 

Definition at line 328 of file form_elm.cpp.

References Form, ParentDfn, ParentIndex, ParentNode, and uint.

00329 {
00330         Form = form;
00331         ParentNode = parentNode;
00332         ParentDfn = parentDfn;
00333         ParentIndex = parentIndex;
00334         Round = 0xffffffff;
00335 }

NLGEORGES::CFormElm::~CFormElm  )  [virtual]
 

Definition at line 339 of file form_elm.cpp.

References clean().

00340 {
00341         clean(); // it's virtual
00342 }


Member Function Documentation

bool NLGEORGES::CFormElm::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
 

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 Create, NLGEORGES::CFormElmArray::Elements, Form, getIternalNodeByName(), isArray(), nlassert, NLGEORGES_FIRST_ROUND, ParentDfn, 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 }

bool NLGEORGES::CFormElm::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
 

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(), Create, NLGEORGES::CFormElmArray::Elements, Form, getIternalNodeByName(), isArray(), nlassert, NLGEORGES_FIRST_ROUND, nlstop, ParentDfn, 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 }

virtual void NLGEORGES::CFormElm::clean void   )  [inline, virtual]
 

Reset contents.

Reimplemented in NLGEORGES::CFormElmStruct, and NLGEORGES::CFormElmArray.

Definition at line 62 of file form_elm.h.

Referenced by ~CFormElm().

00062 {};

bool NLGEORGES::CFormElm::convertValue NLMISC::CRGBA result,
const char *  value
const [inline]
 

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 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 }

bool NLGEORGES::CFormElm::convertValue bool &  result,
const char *  value
const [inline]
 

Definition at line 625 of file form_elm.h.

References NLMISC::strlwr(), value, and 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 }

bool NLGEORGES::CFormElm::convertValue double &  result,
const char *  value
const [inline]
 

Definition at line 607 of file form_elm.h.

References value, and 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 }

bool NLGEORGES::CFormElm::convertValue float &  result,
const char *  value
const [inline]
 

Definition at line 591 of file form_elm.h.

References value, and 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 }

bool NLGEORGES::CFormElm::convertValue uint32 result,
const char *  value
const [inline]
 

Definition at line 572 of file form_elm.h.

References NLMISC::clamp(), sint32, uint32, value, and 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 }

bool NLGEORGES::CFormElm::convertValue sint32 result,
const char *  value
const [inline]
 

Definition at line 553 of file form_elm.h.

References NLMISC::clamp(), sint32, value, and 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 }

bool NLGEORGES::CFormElm::convertValue uint16 result,
const char *  value
const [inline]
 

Definition at line 534 of file form_elm.h.

References NLMISC::clamp(), uint16, value, and 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 }

bool NLGEORGES::CFormElm::convertValue sint16 result,
const char *  value
const [inline]
 

Definition at line 515 of file form_elm.h.

References NLMISC::clamp(), sint16, value, and 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 }

bool NLGEORGES::CFormElm::convertValue uint8 result,
const char *  value
const [inline]
 

Definition at line 496 of file form_elm.h.

References NLMISC::clamp(), uint8, value, and 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 }

bool NLGEORGES::CFormElm::convertValue sint8 result,
const char *  value
const [inline]
 

Definition at line 477 of file form_elm.h.

References NLMISC::clamp(), sint8, value, and warning().

Referenced by NLGEORGES::CFormElmArray::getArrayValue(), NLGEORGES::CFormElmAtom::getValue(), and 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 }

bool NLGEORGES::CFormElm::createNodeByName const char *  name,
const CFormDfn **  parentDfn,
uint indexDfn,
const CFormDfn **  nodeDfn,
const CType **  nodeType,
CFormElm **  node,
UFormDfn::TEntryType type,
bool &  array,
bool &  created
 

Definition at line 596 of file form_elm.cpp.

References Create, Form, getIternalNodeByName(), NLGEORGES_FIRST_ROUND, ParentDfn, ParentIndex, type, and uint.

Referenced by 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 }

bool NLGEORGES::CFormElm::deleteNodeByName const char *  name,
const CFormDfn **  parentDfn,
uint indexDfn,
const CFormDfn **  nodeDfn,
const CType **  nodeType,
CFormElm **  node,
UFormDfn::TEntryType type,
bool &  array
 

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 Delete, Form, getIternalNodeByName(), NLGEORGES_FIRST_ROUND, ParentDfn, 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 }

bool NLGEORGES::CFormElm::getArrayNode UFormElm **  result,
uint  arrayIndex
[virtual]
 

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 warning().

00077 { 
00078         warning (false, "getArrayNode", "This node is not an array.");
00079         return false; 
00080 };

bool NLGEORGES::CFormElm::getArrayNode const UFormElm **  result,
uint  arrayIndex
const [virtual]
 

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 warning().

00069 { 
00070         warning (false, "getArrayNode", "This node is not an array.");
00071         return false; 
00072 };

bool NLGEORGES::CFormElm::getArrayNodeName std::string &  result,
uint  arrayIndex
const [virtual]
 

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 warning().

00085 {
00086         warning (false, "getArrayNodeName", "This node is not an array.");
00087         return false;
00088 }

bool NLGEORGES::CFormElm::getArraySize uint size  )  const [virtual]
 

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 warning().

00061 {
00062         warning (false, "getArraySize", "This node is not an array.");
00063         return false; 
00064 };

bool NLGEORGES::CFormElm::getArrayValue NLMISC::CRGBA result,
uint  arrayIndex,
TEval  evaluate,
TWhereIsValue where
const [virtual]
 

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 warning().

00173 {
00174         warning (false, "getArrayValue", "This node is not an array.");
00175         return false;
00176 }

bool NLGEORGES::CFormElm::getArrayValue bool &  result,
uint  arrayIndex,
TEval  evaluate,
TWhereIsValue where
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmArray.

Definition at line 164 of file form_elm.cpp.

References uint, and warning().

00165 {
00166         warning (false, "getArrayValue", "This node is not an array.");
00167         return false;
00168 }

bool NLGEORGES::CFormElm::getArrayValue double &  result,
uint  arrayIndex,
TEval  evaluate,
TWhereIsValue where
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmArray.

Definition at line 156 of file form_elm.cpp.

References uint, and warning().

00157 {
00158         warning (false, "getArrayValue", "This node is not an array.");
00159         return false;
00160 }

bool NLGEORGES::CFormElm::getArrayValue float &  result,
uint  arrayIndex,
TEval  evaluate,
TWhereIsValue where
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmArray.

Definition at line 148 of file form_elm.cpp.

References uint, and warning().

00149 {
00150         warning (false, "getArrayValue", "This node is not an array.");
00151         return false;
00152 }

bool NLGEORGES::CFormElm::getArrayValue uint32 result,
uint  arrayIndex,
TEval  evaluate,
TWhereIsValue where
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmArray.

Definition at line 140 of file form_elm.cpp.

References uint, uint32, and warning().

00141 {
00142         warning (false, "getArrayValue", "This node is not an array.");
00143         return false;
00144 }

bool NLGEORGES::CFormElm::getArrayValue sint32 result,
uint  arrayIndex,
TEval  evaluate,
TWhereIsValue where
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmArray.

Definition at line 132 of file form_elm.cpp.

References sint32, uint, and warning().

00133 {
00134         warning (false, "getArrayValue", "This node is not an array.");
00135         return false;
00136 }

bool NLGEORGES::CFormElm::getArrayValue uint16 result,
uint  arrayIndex,
TEval  evaluate,
TWhereIsValue where
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmArray.

Definition at line 124 of file form_elm.cpp.

References uint, uint16, and warning().

00125 {
00126         warning (false, "getArrayValue", "This node is not an array.");
00127         return false;
00128 }

bool NLGEORGES::CFormElm::getArrayValue sint16 result,
uint  arrayIndex,
TEval  evaluate,
TWhereIsValue where
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmArray.

Definition at line 116 of file form_elm.cpp.

References sint16, uint, and warning().

00117 {
00118         warning (false, "getArrayValue", "This node is not an array.");
00119         return false;
00120 }

bool NLGEORGES::CFormElm::getArrayValue uint8 result,
uint  arrayIndex,
TEval  evaluate,
TWhereIsValue where
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmArray.

Definition at line 108 of file form_elm.cpp.

References uint, uint8, and warning().

00109 {
00110         warning (false, "getArrayValue", "This node is not an array.");
00111         return false;
00112 }

bool NLGEORGES::CFormElm::getArrayValue sint8 result,
uint  arrayIndex,
TEval  evaluate,
TWhereIsValue where
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmArray.

Definition at line 100 of file form_elm.cpp.

References sint8, uint, and warning().

00101 {
00102         warning (false, "getArrayValue", "This node is not an array.");
00103         return false;
00104 }

bool NLGEORGES::CFormElm::getArrayValue std::string &  result,
uint  arrayIndex,
TEval  evaluate,
TWhereIsValue where
const [virtual]
 

Get an array value. The node must be an array of atom element.

Parameters:
result is a reference on the value to fill with the result.
arrayIndex is the array index to evaluate.
evaluate must be true if you want to have an evaluated value, false if you want the formula value.
where is a pointer on the information flag of the value. If Where is not NULL, it is filled with the position where the value has been found.
Returns:
true if the result has been filled, false if the value has not been found or the cast has failed or the evaluation has failed.

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmArray.

Definition at line 92 of file form_elm.cpp.

References uint, and warning().

00093 {
00094         warning (false, "getArrayNode", "This node is not an array.");
00095         return false;
00096 }

virtual void NLGEORGES::CFormElm::getDependencies std::set< std::string > &  dependencies  )  const [pure virtual]
 

Implemented in NLGEORGES::CFormElmStruct, NLGEORGES::CFormElmArray, and NLGEORGES::CFormElmAtom.

bool NLGEORGES::CFormElm::getDfnName std::string &  dfnName  )  const [virtual]
 

Get the dfn filename for this virtual struct. Must be a virtual struct node.

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmVirtualStruct.

Definition at line 194 of file form_elm.cpp.

00195 {
00196         return false;
00197 }

CForm * NLGEORGES::CFormElm::getForm  )  const
 

Definition at line 353 of file form_elm.cpp.

References Form.

Referenced by warning().

00354 {
00355         return Form;
00356 }

virtual void NLGEORGES::CFormElm::getFormName std::string &  result,
const CFormElm child = NULL
const [pure virtual]
 

Implemented in NLGEORGES::CFormElmStruct, NLGEORGES::CFormElmArray, and NLGEORGES::CFormElmAtom.

Referenced by NLGEORGES::CFormElmAtom::getFormName(), NLGEORGES::CFormElmArray::getFormName(), NLGEORGES::CFormElmStruct::getFormName(), getIternalNodeByName(), and warning().

bool NLGEORGES::CFormElm::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
[static, protected]
 

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(), Create, Delete, NLGEORGES::CFormElmVirtualStruct::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(), getFormName(), NLGEORGES::CFormElmStruct::getFormName(), NLGEORGES::UFormElm::getNodeByName(), NLGEORGES::CForm::getParent(), NLGEORGES::CForm::getParentCount(), NLGEORGES::CForm::getRootNode(), NLGEORGES::CFormDfn::CEntry::getType(), NLGEORGES::CFormDfn::CEntry::getTypePtr(), isArray(), NLGEORGES::UFormElm::isVirtualStruct(), nlassert, NLGEORGES_MAX_RECURSION, nlstop, nlverify, Return, NLMISC::smprintf(), TokenArrayBegin, TokenArrayEnd, tokenize(), TokenPoint, TokenString, NLGEORGES::CType::Type, type, uint, uint32, unlink(), and warning().

Referenced by arrayDeleteNodeByName(), arrayInsertNodeByName(), createNodeByName(), deleteNodeByName(), and 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 }

bool NLGEORGES::CFormElm::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
 

Definition at line 629 of file form_elm.cpp.

References Form, getIternalNodeByName(), ParentDfn, ParentIndex, 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 }

bool NLGEORGES::CFormElm::getNodeByName UFormElm **  result,
const char *  name,
TWhereIsNode where,
bool  verbose,
uint32  round = 0
[virtual]
 

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 }

bool NLGEORGES::CFormElm::getNodeByName const UFormElm **  result,
const char *  name,
TWhereIsNode where,
bool  verbose,
uint32  round = 0
const [virtual]
 

Return a node pointer with its name.

Parameters:
result will be filled with the node pointer. Can be NULL if the node doesn't exist.
name is the form node name
where is a pointer on the information flag of the value. If Where is not NULL, it is filled with the position where the node has been found. If result is NULL, where is undefined.
Returns:
true if the result has been filled, false if the node is not referenced.
About the node existance

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 Form, type, uint, and uint32.

Referenced by 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 }

UFormElm * NLGEORGES::CFormElm::getParent  )  const [virtual]
 

Definition at line 589 of file form_elm.cpp.

References ParentNode.

00590 {
00591         return ParentNode;
00592 }

virtual UFormDfn* NLGEORGES::CFormElm::getStructDfn  )  [inline, virtual]
 

Return the struct dfn.

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmStruct.

Definition at line 134 of file form_elm.h.

00134 { return NULL; }

bool NLGEORGES::CFormElm::getStructNode uint  element,
UFormElm **  result
[virtual]
 

Return a mutable element pointer. Can be NULL if the node doesn't exist.

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmStruct.

Definition at line 225 of file form_elm.cpp.

References uint, and warning().

00226 { 
00227         warning (false, "getStructNode", "This node is not a struct.");
00228         return false; 
00229 };

bool NLGEORGES::CFormElm::getStructNode uint  element,
const UFormElm **  result
const [virtual]
 

Return a const element pointer. Can be NULL if the node doesn't exist.

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmStruct.

Definition at line 217 of file form_elm.cpp.

References uint, and warning().

00218 { 
00219         warning (false, "getStructNode", "This node is not a struct.");
00220         return false; 
00221 };

bool NLGEORGES::CFormElm::getStructNodeName uint  element,
std::string &  result
const [virtual]
 

Return the element name.

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmStruct.

Definition at line 209 of file form_elm.cpp.

References uint, and warning().

00210 { 
00211         warning (false, "getStructNodeName", "This node is not a struct.");
00212         return false; 
00213 };

bool NLGEORGES::CFormElm::getStructSize uint size  )  const [virtual]
 

Return the struct size.

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmStruct.

Definition at line 201 of file form_elm.cpp.

References size, uint, and warning().

00202 { 
00203         warning (false, "getStructSize", "This node is not a struct.");
00204         return false; 
00205 };

bool NLGEORGES::CFormElm::getValue NLMISC::CRGBA resultname,
TEval  evaluate
const [virtual]
 

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 warning().

00321 {
00322         warning (false, "getValue", "This node is not an atom."); 
00323         return false; 
00324 }

bool NLGEORGES::CFormElm::getValue bool &  resultname,
TEval  evaluate
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 312 of file form_elm.cpp.

References warning().

00313 {
00314         warning (false, "getValue", "This node is not an atom."); 
00315         return false; 
00316 }

bool NLGEORGES::CFormElm::getValue double &  resultname,
TEval  evaluate
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 304 of file form_elm.cpp.

References warning().

00305 {
00306         warning (false, "getValue", "This node is not an atom."); 
00307         return false; 
00308 }

bool NLGEORGES::CFormElm::getValue float &  resultname,
TEval  evaluate
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 296 of file form_elm.cpp.

References warning().

00297 {
00298         warning (false, "getValue", "This node is not an atom.");
00299         return false; 
00300 }

bool NLGEORGES::CFormElm::getValue uint32 resultname,
TEval  evaluate
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 288 of file form_elm.cpp.

References uint32, and warning().

00289 {
00290         warning (false, "getValue", "This node is not an atom.");
00291         return false; 
00292 }

bool NLGEORGES::CFormElm::getValue sint32 resultname,
TEval  evaluate
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 280 of file form_elm.cpp.

References sint32, and warning().

00281 {
00282         warning (false, "getValue", "This node is not an atom.");
00283         return false; 
00284 }

bool NLGEORGES::CFormElm::getValue uint16 resultname,
TEval  evaluate
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 272 of file form_elm.cpp.

References uint16, and warning().

00273 {
00274         warning (false, "getValue", "This node is not an atom.");
00275         return false; 
00276 }

bool NLGEORGES::CFormElm::getValue sint16 resultname,
TEval  evaluate
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 264 of file form_elm.cpp.

References sint16, and warning().

00265 {
00266         warning (false, "getValue", "This node is not an atom.");
00267         return false; 
00268 }

bool NLGEORGES::CFormElm::getValue uint8 resultname,
TEval  evaluate
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 256 of file form_elm.cpp.

References uint8, and warning().

00257 {
00258         warning (false, "getValue", "This node is not an atom.");
00259         return false; 
00260 }

bool NLGEORGES::CFormElm::getValue sint8 resultname,
TEval  evaluate
const [virtual]
 

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 248 of file form_elm.cpp.

References sint8, and warning().

00249 {
00250         warning (false, "getValue", "This node is not an atom.");
00251         return false; 
00252 }

bool NLGEORGES::CFormElm::getValue std::string &  resultname,
TEval  evaluate
const [virtual]
 

Return the atom value. The numbers are clamped to the type limit values.

Parameters:
result is the reference on the value to fill with result
evaluate must be true if you want to have an evaluated value, false if you want the formula value.

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 240 of file form_elm.cpp.

References warning().

00241 { 
00242         warning (false, "getValue", "This node is not an atom.");
00243         return false; 
00244 };

bool NLGEORGES::CFormElm::getValueByName NLMISC::CRGBA result,
const char *  name,
TEval  evaluate,
TWhereIsValue where,
uint32  round = 0
const [virtual]
 

Warning, only R, G and B members are filled, not A.

Implements NLGEORGES::UFormElm.

Definition at line 575 of file form_elm.cpp.

References convertValue(), 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 }

bool NLGEORGES::CFormElm::getValueByName bool &  result,
const char *  name,
TEval  evaluate,
TWhereIsValue where,
uint32  round = 0
const [virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 561 of file form_elm.cpp.

References convertValue(), 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 }

bool NLGEORGES::CFormElm::getValueByName double &  result,
const char *  name,
TEval  evaluate,
TWhereIsValue where,
uint32  round = 0
const [virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 547 of file form_elm.cpp.

References convertValue(), 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 }

bool NLGEORGES::CFormElm::getValueByName float &  result,
const char *  name,
TEval  evaluate,
TWhereIsValue where,
uint32  round = 0
const [virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 533 of file form_elm.cpp.

References convertValue(), 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 }

bool NLGEORGES::CFormElm::getValueByName uint32 result,
const char *  name,
TEval  evaluate,
TWhereIsValue where,
uint32  round = 0
const [virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 519 of file form_elm.cpp.

References convertValue(), 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 }

bool NLGEORGES::CFormElm::getValueByName sint32 result,
const char *  name,
TEval  evaluate,
TWhereIsValue where,
uint32  round = 0
const [virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 505 of file form_elm.cpp.

References convertValue(), 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 }

bool NLGEORGES::CFormElm::getValueByName uint16 result,
const char *  name,
TEval  evaluate,
TWhereIsValue where,
uint32  round = 0
const [virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 491 of file form_elm.cpp.

References convertValue(), 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 }

bool NLGEORGES::CFormElm::getValueByName sint16 result,
const char *  name,
TEval  evaluate,
TWhereIsValue where,
uint32  round = 0
const [virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 477 of file form_elm.cpp.

References convertValue(), 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 }

bool NLGEORGES::CFormElm::getValueByName uint8 result,
const char *  name,
TEval  evaluate,
TWhereIsValue where,
uint32  round = 0
const [virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 463 of file form_elm.cpp.

References convertValue(), 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 }

bool NLGEORGES::CFormElm::getValueByName sint8 result,
const char *  name,
TEval  evaluate,
TWhereIsValue where,
uint32  round = 0
const [virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 449 of file form_elm.cpp.

References convertValue(), 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 }

bool NLGEORGES::CFormElm::getValueByName std::string &  result,
const char *  name,
TEval  evaluate,
TWhereIsValue where,
uint32  round = 0
const [virtual]
 

Get a form value with its name. The numbers are clamped to the type limit values.

Parameters:
result is a reference on the value to fill with the result.
name is the form name of the value to found.
evaluate must be true if you want to have an evaluated value, false if you want the formula value.
where is a pointer on the information flag of the value. If Where is not NULL, it is filled with the position where the value has been found.
Returns:
true if the result has been filled, false if the value has not been found or the cast has failed or the evaluation has failed.
See also:
getNodeByName ()

Implements NLGEORGES::UFormElm.

Definition at line 406 of file form_elm.cpp.

References Form, getNodeByName(), NLGEORGES::CType::getValue(), nlassert, type, uint, uint32, and warning().

Referenced by 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 }

bool NLGEORGES::CFormElm::isArray  )  const [virtual]
 

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 arrayDeleteNodeByName(), arrayInsertNodeByName(), and getIternalNodeByName().

00054 { 
00055         return false; 
00056 };

bool NLGEORGES::CFormElm::isAtom  )  const [virtual]
 

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 };

bool NLGEORGES::CFormElm::isStruct  )  const [virtual]
 

Return true if the element is a struct or a virtual struct.

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmStruct.

Definition at line 180 of file form_elm.cpp.

00181 { 
00182         return false; 
00183 };

bool NLGEORGES::CFormElm::isUsed const CForm form  )  const [virtual]
 

Reimplemented in NLGEORGES::CFormElmStruct, NLGEORGES::CFormElmVirtualStruct, and NLGEORGES::CFormElmArray.

Definition at line 346 of file form_elm.cpp.

References Form.

Referenced by NLGEORGES::CFormElmAtom::write().

00347 {
00348         return form == Form;
00349 }

bool NLGEORGES::CFormElm::isVirtualStruct  )  const [virtual]
 

Return true if the element is a virtual struct.

Implements NLGEORGES::UFormElm.

Reimplemented in NLGEORGES::CFormElmVirtualStruct.

Definition at line 187 of file form_elm.cpp.

00188 { 
00189         return false; 
00190 };

bool NLGEORGES::CFormElm::setValueByName NLMISC::CRGBA  value,
const char *  name,
bool *  created
[virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 1647 of file form_elm.cpp.

References 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 }

bool NLGEORGES::CFormElm::setValueByName bool  value,
const char *  name,
bool *  created
[virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 1640 of file form_elm.cpp.

References setValueByName(), NLMISC::toString(), and value.

01641 {
01642         return setValueByName (toString (value).c_str (), name, created);
01643 }

bool NLGEORGES::CFormElm::setValueByName double  value,
const char *  name,
bool *  created
[virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 1633 of file form_elm.cpp.

References setValueByName(), NLMISC::toString(), and value.

01634 {
01635         return setValueByName (toString (value).c_str (), name, created);
01636 }

bool NLGEORGES::CFormElm::setValueByName float  value,
const char *  name,
bool *  created
[virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 1626 of file form_elm.cpp.

References setValueByName(), NLMISC::toString(), and value.

01627 {
01628         return setValueByName (toString (value).c_str (), name, created);
01629 }

bool NLGEORGES::CFormElm::setValueByName uint32  value,
const char *  name,
bool *  created
[virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 1619 of file form_elm.cpp.

References setValueByName(), NLMISC::toString(), uint32, and value.

01620 {
01621         return setValueByName (toString (value).c_str (), name, created);
01622 }

bool NLGEORGES::CFormElm::setValueByName sint32  value,
const char *  name,
bool *  created
[virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 1612 of file form_elm.cpp.

References setValueByName(), sint32, NLMISC::toString(), and value.

01613 {
01614         return setValueByName (toString (value).c_str (), name, created);
01615 }

bool NLGEORGES::CFormElm::setValueByName uint16  value,
const char *  name,
bool *  created
[virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 1605 of file form_elm.cpp.

References setValueByName(), NLMISC::toString(), uint16, and value.

01606 {
01607         return setValueByName (toString (value).c_str (), name, created);
01608 }

bool NLGEORGES::CFormElm::setValueByName sint16  value,
const char *  name,
bool *  created
[virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 1598 of file form_elm.cpp.

References setValueByName(), sint16, NLMISC::toString(), and value.

01599 {
01600         return setValueByName (toString (value).c_str (), name, created);
01601 }

bool NLGEORGES::CFormElm::setValueByName uint8  value,
const char *  name,
bool *  created
[virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 1591 of file form_elm.cpp.

References setValueByName(), NLMISC::toString(), uint8, and value.

01592 {
01593         return setValueByName (toString (value).c_str (), name, created);
01594 }

bool NLGEORGES::CFormElm::setValueByName sint8  value,
const char *  name,
bool *  created
[virtual]
 

Implements NLGEORGES::UFormElm.

Definition at line 1584 of file form_elm.cpp.

References setValueByName(), sint8, NLMISC::toString(), and value.

01585 {
01586         return setValueByName (toString (value).c_str (), name, created);
01587 }

bool NLGEORGES::CFormElm::setValueByName const char *  value,
const char *  name,
bool *  created
[virtual]
 

Set a form value with its name. If the node doesn't exist, it is created.

Parameters:
value is a reference on the value to set in the form.
name is the form name of the value to set or create.
where is a pointer on the information flag of the value. If Where is not NULL, it is filled with the position where the value has been found.
created is a pointer on the creatation flag. If created is not NULL, it is filled with true if the value has been created, false it the value has been filled.
Returns:
true if the value has been set, false if the value has not been found or hasn't been created.

Implements NLGEORGES::UFormElm.

Definition at line 1532 of file form_elm.cpp.

References createNodeByName(), nlassert, NLGEORGES::CFormElmAtom::setValue(), type, uint, value, and warning().

Referenced by 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 }

const char * NLGEORGES::CFormElm::tokenize const char *  name,
std::string &  str,
uint errorIndex,
uint code
[static]
 

Definition at line 1482 of file form_elm.cpp.

References TokenArrayBegin, TokenArrayEnd, TokenPoint, TokenString, and uint.

Referenced by 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 }

void NLGEORGES::CFormElm::unlink CFormElm child  )  [protected, virtual]
 

Unlink a child

Reimplemented in NLGEORGES::CFormElmStruct, and NLGEORGES::CFormElmArray.

Definition at line 1524 of file form_elm.cpp.

References nlstop.

Referenced by getIternalNodeByName().

01525 {
01526         // No children
01527         nlstop;
01528 }

void NLGEORGES::CFormElm::warning bool  exception,
const char *  function,
const char *  format,
... 
const [protected, virtual]
 

Reimplemented in NLGEORGES::CFormElmStruct, NLGEORGES::CFormElmVirtualStruct, NLGEORGES::CFormElmArray, and NLGEORGES::CFormElmAtom.

Definition at line 1671 of file form_elm.cpp.

References format, NLGEORGES::CForm::getFilename(), getForm(), getFormName(), and warning().

01672 {
01673         va_list args;
01674         va_start( args, format );
01675 
01676         string formName;
01677         getFormName (formName);
01678         warning (exception, formName.c_str (), getForm ()->getFilename ().c_str (), function, format, args);
01679 
01680         va_end( args );
01681 }

void NLGEORGES::CFormElm::warning bool  exception,
const char *  formName,
const char *  formFileName,
const char *  function,
const char *  format,
... 
[static, protected]
 

Definition at line 1656 of file form_elm.cpp.

References buffer, format, and NLGEORGES::warning().

Referenced by convertValue(), getArrayNode(), getArrayNodeName(), getArraySize(), getArrayValue(), getIternalNodeByName(), getStructNode(), getStructNodeName(), getStructSize(), getValue(), getValueByName(), setValueByName(), and 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 }

virtual xmlNodePtr NLGEORGES::CFormElm::write xmlNodePtr  node,
const CForm form,
const char *  structName = NULL,
bool  forceWrite = false
const [pure virtual]
 

Implemented in NLGEORGES::CFormElmStruct, NLGEORGES::CFormElmVirtualStruct, NLGEORGES::CFormElmArray, and NLGEORGES::CFormElmAtom.


Friends And Related Function Documentation

friend class CForm [friend]
 

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 50 of file form_elm.h.

friend class CFormDfn [friend]
 

Definition at line 52 of file form_elm.h.

friend class CType [friend]
 

Reimplemented in NLGEORGES::CFormElmAtom.

Definition at line 51 of file form_elm.h.


Field Documentation

CForm* NLGEORGES::CFormElm::Form [protected]
 

Definition at line 231 of file form_elm.h.

Referenced by arrayDeleteNodeByName(), arrayInsertNodeByName(), CFormElm(), createNodeByName(), deleteNodeByName(), getForm(), getNodeByName(), getValueByName(), and isUsed().

const CFormDfn* NLGEORGES::CFormElm::ParentDfn [protected]
 

Definition at line 237 of file form_elm.h.

Referenced by arrayDeleteNodeByName(), arrayInsertNodeByName(), CFormElm(), createNodeByName(), deleteNodeByName(), and getNodeByName().

uint NLGEORGES::CFormElm::ParentIndex [protected]
 

Definition at line 240 of file form_elm.h.

Referenced by arrayDeleteNodeByName(), arrayInsertNodeByName(), CFormElm(), createNodeByName(), deleteNodeByName(), and getNodeByName().

CFormElm* NLGEORGES::CFormElm::ParentNode [protected]
 

Definition at line 234 of file form_elm.h.

Referenced by CFormElm(), and getParent().

uint32 NLGEORGES::CFormElm::Round [protected]
 

Definition at line 243 of file form_elm.h.


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 12:41:52 2004 for NeL by doxygen 1.3.6