Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

configuration.inline.hpp 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. // configuration.inline.hpp
  2. //
  3. // (C) 2006-2009 MicroNeil Research Corporation.
  4. //
  5. // This program is part of the MicroNeil Research Open Library Project. For
  6. // more information go to http://www.microneil.com/OpenLibrary/index.html
  7. //
  8. // This program is free software; you can redistribute it and/or modify it
  9. // under the terms of the GNU General Public License as published by the
  10. // Free Software Foundation; either version 2 of the License, or (at your
  11. // option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful, but WITHOUT
  14. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. // more details.
  17. //
  18. // You should have received a copy of the GNU General Public License along with
  19. // this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  20. // Place, Suite 330, Boston, MA 02111-1307 USA
  21. // See configuration.hpp for details
  22. //// Configuration Element /////////////////////////////////////////////////////
  23. inline ConfigurationElement::ConfigurationElement(const char* Name) : // Construct with a cstring.
  24. myName(std::string(Name)),
  25. myParent(NULL),
  26. myLine(0),
  27. myIndex(0),
  28. myLength(0),
  29. myCleanFlag(true),
  30. myInitOnInterpretFlag(false) {
  31. }
  32. inline ConfigurationElement::ConfigurationElement(const std::string Name) : // Construct with a c++ string.
  33. myName(Name),
  34. myParent(NULL),
  35. myLine(0),
  36. myIndex(0),
  37. myLength(0),
  38. myCleanFlag(true),
  39. myInitOnInterpretFlag(false) {
  40. }
  41. inline ConfigurationElement::ConfigurationElement( // Construct sub element w/ cstring.
  42. const char* Name,
  43. ConfigurationElement& Parent) :
  44. myName(std::string(Name)),
  45. myParent(&Parent),
  46. myLine(0),
  47. myIndex(0),
  48. myLength(0),
  49. myCleanFlag(true),
  50. myInitOnInterpretFlag(false) {
  51. }
  52. inline ConfigurationElement::ConfigurationElement( // Construct sub element w/ string.
  53. const std::string Name,
  54. ConfigurationElement& Parent) :
  55. myName(Name),
  56. myParent(&Parent),
  57. myLine(0),
  58. myIndex(0),
  59. myLength(0),
  60. myCleanFlag(true),
  61. myInitOnInterpretFlag(false) {
  62. }
  63. inline std::string ConfigurationElement::Name() { return myName; } // Get the name of this element.
  64. inline ConfigurationElement& ConfigurationElement::Parent() { // Get the parrent of this element.
  65. if(NULL != myParent) { // If I have a parent
  66. return (*myParent); // then I dereference and return it.
  67. } // If I don't have a parent
  68. return (*this); // then I return myself.
  69. }
  70. inline ConfigurationElement& ConfigurationElement::Parent( // Set the parrent of this element.
  71. ConfigurationElement& Parent) { // Given this parent
  72. myParent = &Parent; // I take and store it's address
  73. return (*myParent); // then dereference and return it.
  74. }
  75. inline int ConfigurationElement::Line() { return myLine; } // Get the last line number.
  76. inline int ConfigurationElement::Index() { return myIndex; } // Get the last data position.
  77. inline int ConfigurationElement::Length() { return myLength; } // Get the last length.
  78. inline void ConfigurationElement::notifyDirty() { myCleanFlag = false; } // Attributes do this when they change.
  79. inline ConfigurationElement& ConfigurationElement::Element(const char* Name) { // Add a new sub element by c string name.
  80. return Element(std::string(Name)); // Use the string name version
  81. }
  82. inline ConfigurationElement& ConfigurationElement::Element(const std::string Name) { // Add a new sub element by c++ string name.
  83. ConfigurationElement* N = new ConfigurationElement( // Create a new Element with the
  84. Name, // name provided and
  85. (*this)); // myself as the parent.
  86. myElements.push_back(N); // Add it to the list.
  87. return (*N); // Return the new element.
  88. }
  89. inline ConfigurationElement& ConfigurationElement::Element( // Mapping factory for convenience,
  90. const char* Name, // requires a name, of course,
  91. ConfigurationTranslator& newTranslator) { // Add a Translator to this element.
  92. return Element(std::string(Name), newTranslator); // Use the string name version
  93. }
  94. inline ConfigurationElement& ConfigurationElement::Element( // Mapping factory for convenience,
  95. const char* Name, // requires a name, of course,
  96. std::string& x, std::string init) { // Map to a string.
  97. return Element(std::string(Name), x, init); // Use the string name version
  98. }
  99. inline ConfigurationElement& ConfigurationElement::Element( // Mapping factory for convenience,
  100. const char* Name, // requires a name, of course,
  101. int& x, int init, int radix) { // Map to an int.
  102. return Element(std::string(Name), x, init, radix); // Use the string name version
  103. }
  104. inline ConfigurationElement& ConfigurationElement::Element( // Mapping factory for convenience,
  105. const char* Name, // requires a name, of course,
  106. double& x, double init) { // Map to a double.
  107. return Element(std::string(Name), x, init); // Use the string name version
  108. }
  109. inline ConfigurationElement& ConfigurationElement::Element( // Mapping factory for convenience,
  110. const char* Name, // requires a name, of course,
  111. bool& x, bool init) { // Map to a boolean.
  112. return Element(std::string(Name), x, init); // Use the string name version
  113. }
  114. inline ConfigurationElement& ConfigurationElement::End() { // Return this element's parent.
  115. return Parent(); // Borrow Parent()
  116. }
  117. inline ConfigurationElement& ConfigurationElement::End(const char* Name) { // Check the name and return the parent
  118. return End(std::string(Name)); // Borrow End(string)
  119. }
  120. inline ConfigurationElement& ConfigurationElement::End(const std::string Name) {// if the name is correct - or throw!
  121. if(0 != Name.compare(myName)) { // If Name is not myName
  122. throw EndNameDoesNotMatch(); // throw an exception!
  123. } // If the names match then
  124. return Parent(); // return the parent.
  125. }
  126. inline ConfigurationAttribute& ConfigurationElement::Attribute( // Add an attribute using a cstring.
  127. const char* Name) { // Given this cstring name
  128. return Attribute(std::string(Name)); // Convert it to a string and borrow
  129. } // Attribute(string)
  130. inline ConfigurationAttribute& ConfigurationElement::Attribute( // Mapping factory for convenience,
  131. const char* Name, // requires a name, of course,
  132. ConfigurationTranslator& newTranslator) { // Add a Translator to this element.
  133. return Attribute(std::string(Name), newTranslator); // Borrow the string name version
  134. }
  135. inline ConfigurationAttribute& ConfigurationElement::Attribute( // Mapping factory for convenience,
  136. const char* Name, // requires a name, of course,
  137. std::string& x, std::string init) { // Map to a string.
  138. return Attribute(std::string(Name), x, init); // Borrow the string name version
  139. }
  140. inline ConfigurationAttribute& ConfigurationElement::Attribute( // Mapping factory for convenience,
  141. const char* Name, // requires a name, of course,
  142. int& x, int init, int radix) { // Map to an int.
  143. return Attribute(std::string(Name), x, init); // Borrow the string name version
  144. }
  145. inline ConfigurationAttribute& ConfigurationElement::Attribute( // Mapping factory for convenience,
  146. const char* Name, // requires a name, of course,
  147. double& x, double init) { // Map to a double.
  148. return Attribute(std::string(Name), x, init); // Borrow the string name version
  149. }
  150. inline ConfigurationAttribute& ConfigurationElement::Attribute( // Mapping factory for convenience,
  151. const char* Name, // requires a name, of course,
  152. bool& x, bool init) { // Map to a boolean.
  153. return Attribute(std::string(Name), x, init); // Borrow the string name version
  154. }
  155. inline ConfigurationElement& ConfigurationElement::setInitOnInterpret() { // Set the init on interpret flag.
  156. myInitOnInterpretFlag = true; // Set the flag.
  157. return(*this); // Dereference and return self.
  158. }
  159. inline ConfigurationElement& ConfigurationElement::atStartCall( // Add an atStart call-back.
  160. Configurator& Functor) { // Given this Functor,
  161. myStartConfigurators.push_back(&Functor); // add it to my atStart list then
  162. return(*this); // dereference and return myself.
  163. }
  164. inline ConfigurationElement& ConfigurationElement::atEndCall( // Add an atEnd call-back.
  165. Configurator& Functor) { // Given this Functor,
  166. myEndConfigurators.push_back(&Functor); // add it to my atEnd list then
  167. return(*this); // dereference and return myself.
  168. }
  169. inline ConfigurationElement& ConfigurationElement::Mnemonic( // Add a mnemonic using c strings.
  170. const char* name, const char* value) { // Given char* and char*
  171. return Mnemonic(std::string(name), std::string(value)); // make strings and borrow that method.
  172. }
  173. inline ConfigurationElement& ConfigurationElement::Mnemonic( // Add a mnemonic using mixed strings.
  174. const char* name, const std::string value) { // Given char* and string
  175. return Mnemonic(std::string(name), value); // make strings and borrow that method.
  176. }
  177. inline ConfigurationElement& ConfigurationElement::Mnemonic( // Add a mnemonic using mixed strings.
  178. const std::string name, const char* value) { // Given string and char*
  179. return Mnemonic(name, std::string(value)); // make strings and borrow that method.
  180. }
  181. inline ConfigurationElement& ConfigurationElement::Mnemonic( // Add a mnemonic using c++ strings.
  182. const std::string name, const std::string value) { // Givent string and string
  183. ConfigurationMnemonic* N = // Create a new Mnemonic
  184. new ConfigurationMnemonic(name, value); // using the values provided,
  185. myMnemonics.push_back(N); // add it to my list, then
  186. return(*this); // dereference and return myself.
  187. }
  188. //// Configuration Attribute ///////////////////////////////////////////////////
  189. inline ConfigurationAttribute::ConfigurationAttribute( // Attributes are constructed with a
  190. const char* Name, ConfigurationElement& Parent) : // Name and a Parent.
  191. myName(std::string(Name)), // We convert the name to a string.
  192. myParent(Parent), // We just grab the parent.
  193. myLine(0), // Everything else gets zeroed.
  194. myIndex(0),
  195. myLength(0) {
  196. }
  197. inline ConfigurationAttribute::ConfigurationAttribute( // Attributes are constrictued with a
  198. const std::string Name, ConfigurationElement& Parent) : // Name and a Parent.
  199. myName(Name), // We grab them and zero the rest.
  200. myParent(Parent),
  201. myLine(0),
  202. myIndex(0),
  203. myLength(0) {
  204. }
  205. inline std::string ConfigurationAttribute::Name() { // Get the name of this attribute.
  206. return myName;
  207. }
  208. inline ConfigurationElement& ConfigurationAttribute::Parent() { // Get the parent of this attribute.
  209. return myParent;
  210. }
  211. inline int ConfigurationAttribute::Line() { // Get the last line number.
  212. return myLine;
  213. }
  214. inline int ConfigurationAttribute::Index() { // Get the last data position.
  215. return myIndex;
  216. }
  217. inline int ConfigurationAttribute::Length() { // Get the last length.
  218. return myLength;
  219. }
  220. inline ConfigurationElement& ConfigurationAttribute::Element( // Add a new sub element by c string name.
  221. const char* Name) {
  222. return myParent.Element(Name);
  223. }
  224. inline ConfigurationElement& ConfigurationAttribute::Element( // Add a new sub element by c++ string name.
  225. const std::string Name) {
  226. return myParent.Element(Name);
  227. }
  228. inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
  229. const char* Name, // requires a name, of course,
  230. ConfigurationTranslator& newTranslator) { // Add a Translator to this element.
  231. return myParent.Element(Name, newTranslator);
  232. }
  233. inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
  234. const char* Name, // requires a name, of course,
  235. std::string& x, std::string init) { // Map to a string.
  236. return myParent.Element(Name, x, init);
  237. }
  238. inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
  239. const char* Name, // requires a name, of course,
  240. int& x, int init, int radix) { // Map to an int.
  241. return myParent.Element(Name, x, init, radix);
  242. }
  243. inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
  244. const char* Name, // requires a name, of course,
  245. double& x, double init) { // Map to a double.
  246. return myParent.Element(Name, x, init);
  247. }
  248. inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
  249. const char* Name, // requires a name, of course,
  250. bool& x, bool init) { // Map to a boolean.
  251. return myParent.Element(Name, x, init);
  252. }
  253. inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
  254. const std::string Name, // requires a name, of course,
  255. ConfigurationTranslator& newTranslator) { // Add a Translator to this element.
  256. return myParent.Element(Name, newTranslator);
  257. }
  258. inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
  259. const std::string Name, // requires a name, of course,
  260. std::string& x, std::string init) { // Map to a string.
  261. return myParent.Element(Name, x, init);
  262. }
  263. inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
  264. const std::string Name, // requires a name, of course,
  265. int& x, int init, int radix) { // Map to an int.
  266. return myParent.Element(Name, x, init, radix);
  267. }
  268. inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
  269. const std::string Name, // requires a name, of course,
  270. double& x, double init) { // Map to a double.
  271. return myParent.Element(Name, x, init);
  272. }
  273. inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
  274. const std::string Name, // requires a name, of course,
  275. bool& x, bool init) { // Map to a boolean.
  276. return myParent.Element(Name, x, init);
  277. }
  278. inline ConfigurationElement& ConfigurationAttribute::End() { // Return this element's parent.
  279. return myParent.End();
  280. }
  281. inline ConfigurationElement& ConfigurationAttribute::End(const char* Name) { // Check the name and return the parent
  282. return myParent.End(Name);
  283. }
  284. inline ConfigurationElement& ConfigurationAttribute::End(const std::string Name) { // if the name is correct - or throw!
  285. return myParent.End(Name);
  286. }
  287. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Add an attribute using a cstring.
  288. const char* Name) {
  289. return myParent.Attribute(Name);
  290. }
  291. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Add an attribute using a c++ string.
  292. const std::string Name) {
  293. return myParent.Attribute(Name);
  294. }
  295. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
  296. const char* Name, // requires a name, of course,
  297. ConfigurationTranslator& newTranslator) { // Add a Translator to this element.
  298. return myParent.Attribute(Name, newTranslator);
  299. }
  300. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
  301. const char* Name, // requires a name, of course,
  302. std::string& x, std::string init) { // Map to a string.
  303. return myParent.Attribute(Name, x, init);
  304. }
  305. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
  306. const char* Name, // requires a name, of course,
  307. int& x, int init, int radix) { // Map to an int.
  308. return myParent.Attribute(Name, x, init, radix);
  309. }
  310. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
  311. const char* Name, // requires a name, of course,
  312. double& x, double init) { // Map to a double.
  313. return myParent.Attribute(Name, x, init);
  314. }
  315. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
  316. const char* Name, // requires a name, of course,
  317. bool& x, bool init) { // Map to a boolean.
  318. return myParent.Attribute(Name, x, init);
  319. }
  320. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
  321. const std::string Name, // requires a name, of course,
  322. ConfigurationTranslator& newTranslator) { // Add a Translator to this element.
  323. return myParent.Attribute(Name, newTranslator);
  324. }
  325. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
  326. const std::string Name, // requires a name, of course,
  327. std::string& x, std::string init) { // Map to a string.
  328. return myParent.Attribute(Name, x, init);
  329. }
  330. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
  331. const std::string Name, // requires a name, of course,
  332. int& x, int init, int radix) { // Map to an int.
  333. return myParent.Attribute(Name, x, init, radix);
  334. }
  335. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
  336. const std::string Name, // requires a name, of course,
  337. double& x, double init) { // Map to a double.
  338. return myParent.Attribute(Name, x, init);
  339. }
  340. inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
  341. const std::string Name, // requires a name, of course,
  342. bool& x, bool init) { // Map to a boolean.
  343. return myParent.Attribute(Name, x, init);
  344. }
  345. inline ConfigurationElement& ConfigurationAttribute::setInitOnInterpret() { // Set the init on interpret flag.
  346. return myParent.setInitOnInterpret();
  347. }
  348. inline ConfigurationElement& ConfigurationAttribute::atStartCall( // Add an atStart call-back to this element.
  349. Configurator& Functor) {
  350. return myParent.atStartCall(Functor);
  351. }
  352. inline ConfigurationElement& ConfigurationAttribute::atEndCall( // Add an atEnd call-back to this element.
  353. Configurator& Functor) {
  354. return myParent.atEndCall(Functor);
  355. }
  356. inline ConfigurationAttribute& ConfigurationAttribute::Mnemonic( // Add a mnemonic using c strings.
  357. const char* name, const char* value) { // Given char* and char*
  358. return Mnemonic(std::string(name), std::string(value)); // make strings and borrow that method.
  359. }
  360. inline ConfigurationAttribute& ConfigurationAttribute::Mnemonic( // Add a mnemonic using mixed strings.
  361. const char* name, const std::string value) { // Given char* and string
  362. return Mnemonic(std::string(name), value); // make strings and borrow that method.
  363. }
  364. inline ConfigurationAttribute& ConfigurationAttribute::Mnemonic( // Add a mnemonic using mixed strings.
  365. const std::string name, const char* value) { // Given string and char*
  366. return Mnemonic(name, std::string(value)); // make strings and borrow that method.
  367. }
  368. inline ConfigurationAttribute& ConfigurationAttribute::Mnemonic( // Add a mnemonic using c++ strings.
  369. const std::string name, const std::string value) { // Givent string and string
  370. ConfigurationMnemonic* N = // Create a new Mnemonic
  371. new ConfigurationMnemonic(name, value); // using the values provided,
  372. myMnemonics.push_back(N); // add it to my list, then
  373. return(*this); // dereference and return myself.
  374. }
  375. //// Configuration Data ////////////////////////////////////////////////////////
  376. inline char ConfigurationData::Data(int Index) { // Returns char from Data[Index]
  377. if(0 > Index || Index >= myBufferSize) { // Check that index is in range
  378. return 0; // and return 0 if it is not.
  379. } // If Index is within range then
  380. return myDataBuffer[Index]; // return the byte requested.
  381. }
  382. inline int ConfigurationData::Index() { // Reads the current Index.
  383. return myIndex;
  384. }
  385. inline int ConfigurationData::Index(int i) { // Changes the current Index.
  386. if(0 > i || i >= myBufferSize) { // If i is out of range then
  387. return myIndex; // return the current Index unchanged.
  388. } // If i is within range then
  389. myIndex = i; // change the Index to i and
  390. return myIndex; // return the changed Index.
  391. }
  392. inline int ConfigurationData::Line() { // Reads the current Line number.
  393. return myLine;
  394. }
  395. inline int ConfigurationData::addNewLines(int Count) { // Increments the Line number.
  396. myLine += Count; // Add the number of new lines.
  397. return myLine; // Return the current Line number.
  398. }
  399. //// Configuration Translator //////////////////////////////////////////////////
  400. inline StringTranslator::StringTranslator( // Construct this with
  401. std::string& Variable, // the variable to map,
  402. std::string Initializer) : // and the default value.
  403. myVariable(Variable),
  404. myInitializer(Initializer) {
  405. }
  406. inline void StringTranslator::translate(const char* Value) { // Provide a translation method.
  407. myVariable = std::string(Value); // String to String = simple copy.
  408. }
  409. inline void StringTranslator::initialize() { // Provide an initialization method.
  410. myVariable = myInitializer; // Revert to the initializer value.
  411. }
  412. inline IntegerTranslator::IntegerTranslator( // Construct this with
  413. int& Variable, // the variable to map,
  414. int Initializer, // and the default value.
  415. int Radix) : // For this one we also need a Radix.
  416. myVariable(Variable),
  417. myInitializer(Initializer),
  418. myRadix(Radix) {
  419. }
  420. inline void IntegerTranslator::translate(const char* Value) { // Provide a translation method.
  421. char* dummy; // Throw away ptr for strtol().
  422. myVariable = strtol(Value, &dummy, myRadix); // Convert the string w/ strtol().
  423. }
  424. inline void IntegerTranslator::initialize() { // Provide an initialization method.
  425. myVariable = myInitializer; // Revert to the initializer value.
  426. }
  427. inline DoubleTranslator::DoubleTranslator( // Construct this with
  428. double& Variable, // the variable to map,
  429. double Initializer) : // and the default value.
  430. myVariable(Variable),
  431. myInitializer(Initializer) {
  432. }
  433. inline void DoubleTranslator::translate(const char* Value) { // Provide a translation method.
  434. char* dummy; // Throw away ptr for strtod().
  435. myVariable = strtod(Value, &dummy); // Convert the string w/ strtod().
  436. }
  437. inline void DoubleTranslator::initialize() { // Provide an initialization method.
  438. myVariable = myInitializer; // Revert to the initializer value.
  439. }
  440. inline BoolTranslator::BoolTranslator( // Construct this with
  441. bool& Variable, // the variable to map,
  442. bool Initializer) : // and the default value.
  443. myVariable(Variable),
  444. myInitializer(Initializer) {
  445. }
  446. inline void BoolTranslator::translate(const char* Value) { // Provide a translation method.
  447. if(
  448. (0 == strcmp(Value,"on")) ||
  449. (0 == strcmp(Value,"true")) || // on, true, yes, and 1 are
  450. (0 == strcmp(Value, "yes")) || // interpreted as a boolean true.
  451. (0 == strcmp(Value, "1"))
  452. ) {
  453. myVariable = true;
  454. } else { // Anything else is interpreted as
  455. myVariable = false; // boolean false.
  456. }
  457. }
  458. inline void BoolTranslator::initialize() { // Provide an initialization method.
  459. myVariable = myInitializer; // Revert to the initializer value.
  460. }
  461. //// Configuration Mnemonic ////////////////////////////////////////////////////
  462. inline ConfigurationMnemonic::ConfigurationMnemonic( // To make one, provide both parts.
  463. std::string Name, std::string Value) :
  464. myName(Name),
  465. myValue(Value) {
  466. }
  467. inline bool ConfigurationMnemonic::test(std::string Name) { // Test to see if this Mnemonic matches.
  468. return (0 == Name.compare(myName)); // Return true if Name and myName match.
  469. }
  470. inline std::string ConfigurationMnemonic::Value() { // If it does then we will need it's value.
  471. return myValue;
  472. }