| 198 | } |
| 199 | |
| 200 | bool Settings::write() |
| 201 | { |
| 202 | // Fetch Dynamic-Field Dictionary. |
| 203 | SimFieldDictionary* pFieldDictionary = getFieldDictionary(); |
| 204 | |
| 205 | // Any Field Dictionary? |
| 206 | if ( pFieldDictionary == NULL ) |
| 207 | { |
| 208 | // No, so we're done. |
| 209 | return false; |
| 210 | } |
| 211 | |
| 212 | /* |
| 213 | // Iterate fields. |
| 214 | for ( SimFieldDictionaryIterator itr(pFieldDictionary); *itr; ++itr ) |
| 215 | { |
| 216 | // Fetch Field Entry. |
| 217 | SimFieldDictionary::Entry* fieldEntry = *itr; |
| 218 | |
| 219 | String check(fieldEntry->slotName); |
| 220 | String::SizeType pos = check.find("_default"); |
| 221 | if(pos != String::NPos) |
| 222 | continue; |
| 223 | |
| 224 | // let's build our XML doc |
| 225 | document->pushNewElement("dynamicField"); |
| 226 | document->setAttribute("name", fieldEntry->slotName); |
| 227 | document->addText(fieldEntry->value); |
| 228 | document->popElement(); |
| 229 | } |
| 230 | */ |
| 231 | SimXMLDocument *document = new SimXMLDocument(); |
| 232 | document->registerObject(); |
| 233 | document->addHeader(); |
| 234 | |
| 235 | document->pushNewElement(getName()); |
| 236 | |
| 237 | SettingSaveNode *node = new SettingSaveNode(); |
| 238 | // Iterate fields. |
| 239 | for ( SimFieldDictionaryIterator itr(pFieldDictionary); *itr; ++itr ) |
| 240 | { |
| 241 | // Fetch Field Entry. |
| 242 | SimFieldDictionary::Entry* fieldEntry = *itr; |
| 243 | |
| 244 | String check(fieldEntry->slotName); |
| 245 | if(check.find("_default") != String::NPos || check.find("_type") != String::NPos) |
| 246 | continue; |
| 247 | |
| 248 | node->addValue(fieldEntry->slotName, fieldEntry->value); |
| 249 | } |
| 250 | |
| 251 | node->buildDocument(document, true); |
| 252 | node->clear(); |
| 253 | delete node; |
| 254 | |
| 255 | bool saved = document->saveFile(mFile); |
| 256 | document->deleteObject(); |
| 257 |
no test coverage detected