Changeset 7401 for code/trunk/src/libraries/core/XMLPort.h
- Timestamp:
- Sep 11, 2010, 12:34:00 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/doc (added) merged: 7290-7292,7296-7300,7302-7304,7306-7312,7315-7318,7323,7325,7327,7331-7332,7334-7335,7345-7347,7352-7353,7356-7357,7361,7363-7367,7371-7375,7388
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/XMLPort.h
r7284 r7401 28 28 29 29 /** 30 @defgroup XMLPort XMLPort 31 @ingroup XML 32 */ 33 34 /** 30 35 @file 36 @ingroup XML XMLPort 31 37 @brief Declaration of the XMLPort helper classes and macros. 32 38 … … 69 75 70 76 In the XML file, a param or attribute will be set like this: 77 @code 71 78 <classname paramname="value" /> 79 @endcode 72 80 73 81 The macro will then call loadfunction(value) to set the given value (or call savefunction() to … … 88 96 89 97 In the XML file, a param or attribute will be set like this: 98 @code 90 99 <classname paramname="value" /> 100 @endcode 91 101 92 102 The macro will then store "value" in the variable or read it when saving. … … 148 158 @param paramname The name of the attribute 149 159 @param loadfunction The function to set the attribute inside of the member object. 150 @param loadfunction The function to get the attribute from the member object 160 @param savefunction The function to get the attribute from the member object 161 @param xmlelement The XML-element that is parsed by this macro 162 @param mode Loading or saving 151 163 152 164 Sometimes you'll have a member object in your class, which has it's own load- and savefunctions. 153 165 With this macro, you can simply use them instead of writing your own functions. 154 166 155 @example167 Example: 156 168 Your class is called SpaceShip and this class has an object (myPilot_) of class Pilot. Pilot has a name 157 169 and two functions, setName(name) and getName(). Now you want an attribute "pilotname" in your … … 196 208 @param sectionname The name of the subsection in the XML file that encloses the sub-objects ("" means no subsection) 197 209 @param loadfunction The function to add a new object to the class 198 @param loadfunction The function to get all added objects from the class210 @param savefunction The function to get all added objects from the class 199 211 @param xmlelement The XMLElement (received through the XMLPort function) 200 212 @param mode The mode (load/save) (received through the XMLPort function) … … 210 222 likely the best option, so this is usually true. 211 223 212 @ note224 @details 213 225 The load- and savefunctions have to follow an exactly defined protocol. 214 226 Loadfunction: 215 227 The loadfunction gets a pointer to the object. 216 > void loadfunction(objectclass* pointer); 228 @code 229 void loadfunction(objectclass* pointer); 230 @endcode 217 231 218 232 Savefunction: … … 220 234 gets called again, but with index + 1. It's the functions responsibility to do something smart 221 235 with the index and to return 0 if all objects were returned. 222 > objectclass* savefunction(unsigned int index) const; 236 @code 237 objectclass* savefunction(unsigned int index) const; 238 @endcode 223 239 224 240 Possible implementation: 241 @code 225 242 objectclass* savefunction(unsigned int index) const 226 243 { … … 230 247 return 0; 231 248 } 232 233 @example 249 @endcode 250 251 Example: 234 252 Possible usage of the macro: 235 > XMLPortObject(SpaceShip, Weapon, "weapons", addWeapon, getWeapon, xmlelement, mode, false, true); 253 @code 254 XMLPortObject(SpaceShip, Weapon, "weapons", addWeapon, getWeapon, xmlelement, mode, false, true); 255 @endcode 236 256 237 257 Now you can add weapons through the XML file: 258 @code 238 259 <SpaceShip someattribute="..." ...> 239 260 <weapons> … … 243 264 </weapons> 244 265 </SpaceShip> 266 @endcode 245 267 246 268 Note that "weapons" is the subsection. This allows you to add more types of sub-objects. In our example,
Note: See TracChangeset
for help on using the changeset viewer.