Changeset 7298 for code/branches/doc/src/libraries/core
- Timestamp:
- Aug 31, 2010, 8:56:01 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/doc/src/libraries/core/XMLPort.h
r7297 r7298 69 69 70 70 In the XML file, a param or attribute will be set like this: 71 @code 71 72 <classname paramname="value" /> 73 @endcode 72 74 73 75 The macro will then call loadfunction(value) to set the given value (or call savefunction() to … … 88 90 89 91 In the XML file, a param or attribute will be set like this: 92 @code 90 93 <classname paramname="value" /> 94 @endcode 91 95 92 96 The macro will then store "value" in the variable or read it when saving. … … 212 216 likely the best option, so this is usually true. 213 217 214 @ note218 @details 215 219 The load- and savefunctions have to follow an exactly defined protocol. 216 220 Loadfunction: 217 221 The loadfunction gets a pointer to the object. 218 > void loadfunction(objectclass* pointer); 222 @code 223 void loadfunction(objectclass* pointer); 224 @endcode 219 225 220 226 Savefunction: … … 222 228 gets called again, but with index + 1. It's the functions responsibility to do something smart 223 229 with the index and to return 0 if all objects were returned. 224 > objectclass* savefunction(unsigned int index) const; 230 @code 231 objectclass* savefunction(unsigned int index) const; 232 @endcode 225 233 226 234 Possible implementation: 235 @code 227 236 objectclass* savefunction(unsigned int index) const 228 237 { … … 232 241 return 0; 233 242 } 243 @endcode 234 244 235 245 Example: 236 246 Possible usage of the macro: 237 > XMLPortObject(SpaceShip, Weapon, "weapons", addWeapon, getWeapon, xmlelement, mode, false, true); 247 @code 248 XMLPortObject(SpaceShip, Weapon, "weapons", addWeapon, getWeapon, xmlelement, mode, false, true); 249 @endcode 238 250 239 251 Now you can add weapons through the XML file: 252 @code 240 253 <SpaceShip someattribute="..." ...> 241 254 <weapons> … … 245 258 </weapons> 246 259 </SpaceShip> 260 @endcode 247 261 248 262 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.