#include <type.h>
Inheritance diagram for NLGEORGES::CType:

Definition at line 42 of file type.h.
Public Types | |
| enum | TType { UnsignedInt = 0, SignedInt, Double, String, Color, TypeCount } |
| enum | TUI { Edit, EditSpin, NonEditableCombo, FileBrowser, BigEdit, ColorEdit, UITypeCount } |
Public Member Functions | |
| CType () | |
| virtual const std::string & | getComment () const |
| virtual const std::string & | getDefault () const |
| virtual bool | getDefinition (uint index, std::string &label, std::string &value) const |
| virtual void | getDependencies (std::set< std::string > &dependencies) const |
| virtual const std::string & | getIncrement () const |
| virtual const std::string & | getMax () const |
| virtual const std::string & | getMin () const |
| virtual uint | getNumDefinition () const |
| const sint & | getRefCount () const |
| virtual TType | getType () const |
| bool | getValue (std::string &result, const class CForm *form, const class CFormElmAtom *node, const class CFormDfn &parentDfn, uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const char *formName) const |
| void | write (xmlDocPtr doc, bool georges4CVS) const |
| virtual | ~CType () |
Static Public Member Functions | |
| const char * | getTypeName (UType::TType type) |
| const char * | getUIName (TUI type) |
| bool | uiCompatible (TType type, TUI ui) |
Data Fields | |
| sint | crefs |
| std::string | Default |
| std::vector< CDefinition > | Definitions |
| CFileHeader | Header |
| std::string | Increment |
| std::string | Max |
| std::string | Min |
| CPtrInfo * | pinfo |
| UType::TType | Type |
| TUI | UIType |
Static Public Attributes | |
| CPtrInfo | NullPtrInfo |
Private Member Functions | |
| void | read (xmlNodePtr root) |
| virtual void | warning (bool exception, const char *formName, const char *formFilename, const char *function, const char *format,...) const |
| virtual void | warning2 (bool exception, const char *function, const char *format,...) const |
Static Private Attributes | |
| const char * | TypeNames [] |
| const char * | UITypeNames [] |
Friends | |
| class | CFormLoader |
| struct | CPtrInfo |
|
|
Definition at line 49 of file u_type.h.
|
|
|
Definition at line 51 of file type.h. Referenced by read().
00052 {
00053 Edit, // Default, for all types
00054 EditSpin, // For number types
00055 NonEditableCombo, // For all types
00056 FileBrowser, // Browse file
00057 BigEdit, // Edit a huge text
00058 ColorEdit, // Edit a color
00059 UITypeCount
00060 };
|
|
|
Definition at line 52 of file type.cpp.
00053 {
00054 Type = UnsignedInt;
00055 UIType = Edit;
00056 }
|
|
|
Definition at line 60 of file type.cpp.
00061 {
00062 // int toto = 0;
00063 }
|
|
|
Get theh comments of type. Implements NLGEORGES::UType. Definition at line 908 of file type.cpp. References NLGEORGES::CFileHeader::Comments.
00909 {
00910 return Header.Comments;
00911 }
|
|
|
Get the default value of this type. Implements NLGEORGES::UType. Definition at line 859 of file type.cpp.
00860 {
00861 return Default;
00862 }
|
|
||||||||||||||||
|
Get a definition for this type. index is the index of the defnition you want to get. If the method returns true, label will be filled with the definition label and value will be filled with the defnition value. The method returns false if the index is invalid. In this case, label and value are not changed. Implements NLGEORGES::UType. Definition at line 894 of file type.cpp. References Definitions, index, uint, value, and warning2().
00895 {
00896 if (index < Definitions.size ())
00897 {
00898 label = Definitions[index].Label;
00899 value = Definitions[index].Value;
00900 return true;
00901 }
00902 warning2 (false, "getDefinition", "Index out of bounds (%d >= %d)", index, Definitions.size ());
00903 return false;
00904 }
|
|
|
Get dependency files Implements NLGEORGES::UType. Definition at line 915 of file type.cpp. Referenced by NLGEORGES::CFormElmArray::getDependencies().
00916 {
00917
00918 }
|
|
|
Get the increment value of this type. Implements NLGEORGES::UType. Definition at line 880 of file type.cpp. References Increment.
00881 {
00882 return Increment;
00883 }
|
|
|
Get the max value of this type. Implements NLGEORGES::UType. Definition at line 873 of file type.cpp. References Max.
00874 {
00875 return Max;
00876 }
|
|
|
Get the min value of this type. Implements NLGEORGES::UType. Definition at line 866 of file type.cpp. References Min.
00867 {
00868 return Min;
00869 }
|
|
|
Get the definition count for this type. Implements NLGEORGES::UType. Definition at line 887 of file type.cpp. References Definitions, and uint.
00888 {
00889 return Definitions.size ();
00890 }
|
|
|
Definition at line 70 of file smart_ptr.h. References NLMISC::CRefCount::crefs, and sint.
00071 {
00072 return crefs;
00073 }
|
|
|
Get the type of this type. Implements NLGEORGES::UType. Definition at line 852 of file type.cpp.
00853 {
00854 return Type;
00855 }
|
|
|
|
|
|
Definition at line 324 of file type.cpp. References type, and UITypeNames.
00325 {
00326 return UITypeNames[type];
00327 }
|
|
||||||||||||||||||||||||||||||||||||||||
|
Referenced by NLGEORGES::CMyEvalNumExpr::evalValue(), NLGEORGES::CFormElmArray::getArrayValue(), NLGEORGES::CFormElmAtom::getValue(), and NLGEORGES::CFormElm::getValueByName(). |
|
|
Definition at line 116 of file type.cpp. References Definitions, Edit, Increment, Max, Min, nlassert, NLGEORGES::CFileHeader::read(), TUI, type, TypeNames, uint, UIType, UITypeCount, UITypeNames, value, and warning2().
00117 {
00118 // Check node name
00119 if ( ((const char*)root->name == NULL) || (strcmp ((const char*)root->name, "TYPE") != 0) )
00120 {
00121 // Throw exception
00122 warning2 (true, "read", "XML Syntax error in block line %d, node (%s) should be TYPE.",
00123 (int)root->content, root->name);
00124 }
00125
00126 // Read the type
00127 const char *value = (const char*)xmlGetProp (root, (xmlChar*)"Type");
00128 if (value)
00129 {
00130 // Lookup type
00131 uint type;
00132 for (type=0; type<TypeCount; type++)
00133 {
00134 if (strcmp (value, TypeNames[type]) == 0)
00135 break;
00136 }
00137
00138 // Type found ?
00139 if (type!=TypeCount)
00140 Type = (TType)type;
00141 else
00142 {
00143 // Make an error message
00144 string valueStr = value;
00145
00146 // Delete the value
00147 xmlFree ((void*)value);
00148
00149 // Throw exception
00150 warning2 (true, "read", "XML Syntax error in TYPE block line %d, the Type value is unknown (%s).",
00151 (int)root->content, valueStr.c_str ());
00152 }
00153
00154 // Delete the value
00155 xmlFree ((void*)value);
00156 }
00157 else
00158 {
00159 // Throw exception
00160 warning2 (true, "read", "XML Syntax error in TYPE block line %d, the Type argument was not found.",
00161 (int)root->content);
00162 }
00163
00164 // Read the UI
00165 value = (const char*)xmlGetProp (root, (xmlChar*)"UI");
00166 if (value)
00167 {
00168 // Lookup type
00169 uint type;
00170 for (type=0; type<UITypeCount; type++)
00171 {
00172 if (strcmp (value, UITypeNames[type]) == 0)
00173 break;
00174 }
00175
00176 // Type found ?
00177 if (type!=UITypeCount)
00178 UIType = (TUI)type;
00179 else
00180 UIType = Edit;
00181
00182 // Delete the value
00183 xmlFree ((void*)value);
00184 }
00185 else
00186 UIType = Edit;
00187
00188 // Read Default
00189 value = (const char*)xmlGetProp (root, (xmlChar*)"Default");
00190 if (value)
00191 {
00192 Default = value;
00193
00194 // Delete the value
00195 xmlFree ((void*)value);
00196 }
00197 else
00198 Default = "";
00199
00200 // Read Min
00201 value = (const char*)xmlGetProp (root, (xmlChar*)"Min");
00202 if (value)
00203 {
00204 Min = value;
00205
00206 // Delete the value
00207 xmlFree ((void*)value);
00208 }
00209 else
00210 Min = "";
00211
00212 // Read Max
00213 value = (const char*)xmlGetProp (root, (xmlChar*)"Max");
00214 if (value)
00215 {
00216 Max = value;
00217
00218 // Delete the value
00219 xmlFree ((void*)value);
00220 }
00221 else
00222 Max = "";
00223
00224 // Read Increment
00225 value = (const char*)xmlGetProp (root, (xmlChar*)"Increment");
00226 if (value)
00227 {
00228 Increment = value;
00229
00230 // Delete the value
00231 xmlFree ((void*)value);
00232 }
00233 else
00234 Increment = "";
00235
00236 // Read the definitions
00237 uint childrenCount = CIXml::countChildren (root, "DEFINITION");
00238
00239 // Resize the array
00240 Definitions.resize (childrenCount);
00241 uint child=0;
00242 xmlNodePtr childPtr = CIXml::getFirstChildNode (root, "DEFINITION");
00243 while (child < childrenCount)
00244 {
00245 // Should not be NULL
00246 nlassert (childPtr);
00247
00248 // Read Default
00249 const char *label = (const char*)xmlGetProp (childPtr, (xmlChar*)"Label");
00250 if (label)
00251 {
00252 // Read Default
00253 value = (const char*)xmlGetProp (childPtr, (xmlChar*)"Value");
00254 if (value)
00255 {
00256 Definitions[child].Label = label;
00257 Definitions[child].Value = value;
00258
00259 // Delete the value
00260 xmlFree ((void*)value);
00261 }
00262 else
00263 {
00264 // Delete the value
00265 xmlFree ((void*)label);
00266
00267 // Throw exception
00268 warning2 (true, "read", "XML Syntax error in DEFINITION block line %d, the Value argument was not found.",
00269 (int)childPtr->content);
00270 }
00271
00272 // Delete the value
00273 xmlFree ((void*)label);
00274 }
00275 else
00276 {
00277 // Throw exception
00278 warning2 (true, "read", "XML Syntax error in DEFINITION block line %d, the Label argument was not found.",
00279 (int)childPtr->content);
00280 }
00281
00282 // One more
00283 child++;
00284
00285 childPtr = CIXml::getNextChildNode (childPtr, "DEFINITION");;
00286 }
00287
00288 // Read the header
00289 Header.read (root);
00290 }
|
|
||||||||||||
|
Definition at line 803 of file type.cpp. References BigEdit, ColorEdit, Edit, EditSpin, FileBrowser, NonEditableCombo, and type.
00804 {
00805 switch (type)
00806 {
00807 case UnsignedInt:
00808 case SignedInt:
00809 case Double:
00810 return (ui == Edit) || (ui == EditSpin) || (ui == NonEditableCombo);
00811 case String:
00812 return (ui == Edit) || (ui == NonEditableCombo) || (ui == FileBrowser) || (ui == BigEdit);
00813 case Color:
00814 return (ui == ColorEdit);
00815 default: break;
00816 }
00817 return false;
00818 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 822 of file type.cpp. References buffer, format, and NLGEORGES::warning().
00823 {
00824 // Make a buffer string
00825 va_list args;
00826 va_start( args, format );
00827 char buffer[1024];
00828 vsnprintf( buffer, 1024, format, args );
00829 va_end( args );
00830
00831 // Set the warning
00832 NLGEORGES::warning (exception, "(CType::%s) In form (%s) in node (%s) : %s", function, formFilename, formName, buffer);
00833 }
|
|
||||||||||||||||||||
|
Definition at line 837 of file type.cpp. References buffer, format, and NLGEORGES::warning(). Referenced by getDefinition(), and read().
00838 {
00839 // Make a buffer string
00840 va_list args;
00841 va_start( args, format );
00842 char buffer[1024];
00843 vsnprintf( buffer, 1024, format, args );
00844 va_end( args );
00845
00846 // Set the warning
00847 NLGEORGES::warning (exception, "(CType::%s) : %s", function, buffer);
00848 }
|
|
||||||||||||
|
Definition at line 67 of file type.cpp. References Definitions, Increment, Max, Min, TypeNames, uint, UIType, UITypeNames, and NLGEORGES::CFileHeader::write().
00068 {
00069 // Create the first node
00070 xmlNodePtr node = xmlNewDocNode (doc, NULL, (const xmlChar*)"TYPE", NULL);
00071 xmlDocSetRootElement (doc, node);
00072
00073 // Type
00074 xmlSetProp (node, (const xmlChar*)"Type", (const xmlChar*)TypeNames[Type]);
00075 xmlSetProp (node, (const xmlChar*)"UI", (const xmlChar*)UITypeNames[UIType]);
00076
00077 // Default valid
00078 if (!Default.empty())
00079 {
00080 xmlSetProp (node, (const xmlChar*)"Default", (const xmlChar*)Default.c_str());
00081 }
00082
00083 // Min valid
00084 if (!Min.empty())
00085 {
00086 xmlSetProp (node, (const xmlChar*)"Min", (const xmlChar*)Min.c_str());
00087 }
00088
00089 // Max valid
00090 if (!Max.empty())
00091 {
00092 xmlSetProp (node, (const xmlChar*)"Max", (const xmlChar*)Max.c_str());
00093 }
00094
00095 // Increment valid
00096 if (!Increment.empty())
00097 {
00098 xmlSetProp (node, (const xmlChar*)"Increment", (const xmlChar*)Increment.c_str());
00099 }
00100
00101 // Definition
00102 uint def = 0;
00103 for (def = 0; def<Definitions.size(); def++)
00104 {
00105 xmlNodePtr defNode = xmlNewChild ( node, NULL, (const xmlChar*)"DEFINITION", NULL);
00106 xmlSetProp (defNode, (const xmlChar*)"Label", (const xmlChar*)Definitions[def].Label.c_str());
00107 xmlSetProp (defNode, (const xmlChar*)"Value", (const xmlChar*)Definitions[def].Value.c_str());
00108 }
00109
00110 // Header
00111 Header.write (node, georges4CVS);
00112 }
|
|
|
|
|
|
Definition at line 67 of file smart_ptr.h. |
|
|
Definition at line 79 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount(). |
|
|
|
|
|
Definition at line 105 of file type.h. Referenced by NLGEORGES::CMyEvalNumExpr::evalValue(), getDefinition(), getNumDefinition(), read(), and write(). |
|
|
|
|
|
Definition at line 87 of file type.h. Referenced by getIncrement(), read(), and write(). |
|
|
|
|
|
|
|
|
Referenced by NLMISC::CRefCount::CRefCount(). |
|
|
Definition at line 80 of file smart_ptr.h. Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount(). |
|
|
Definition at line 72 of file type.h. Referenced by NLGEORGES::CFormElm::getIternalNodeByName(). |
|
|
Initial value:
{
"UnsignedInt",
"SignedInt",
"Double",
"String",
"Color",
}
|
|
|
|
|
|
Initial value:
{
"Edit",
"EditSpin",
"NonEditableCombo",
"FileBrowser",
"BigEdit",
"ColorEdit",
}
Definition at line 305 of file type.cpp. Referenced by getUIName(), read(), and write(). |
1.3.6