Переглянути джерело

Placed objects in CodeDweller namespace.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@52 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz 10 роки тому
джерело
коміт
bf633446e3
3 змінених файлів з 133 додано та 129 видалено
  1. 3
    0
      configuration.cpp
  2. 70
    69
      configuration.hpp
  3. 60
    60
      configuration.inline.hpp

+ 3
- 0
configuration.cpp Переглянути файл

@@ -25,6 +25,8 @@

using namespace std;

namespace CodeDweller {

//// Helper functions //////////////////////////////////////////////////////////

// isNameChar(const char x)
@@ -1240,3 +1242,4 @@ void ConfiguratorSetTrueOnComplete::operator()(
} // true.
}

}

+ 70
- 69
configuration.hpp Переглянути файл

@@ -115,7 +115,7 @@
#include <cstdlib>
#include <list>

using namespace std;
namespace CodeDweller {

class ConfigurationElement; // Elements exist
class ConfigurationAttribute; // Attributes exist
@@ -134,21 +134,21 @@ class ConfigurationElement {

private:

string myName; // Elements have a name.
std::string myName; // Elements have a name.

// External important things I remember but don't touch...

ConfigurationElement* myParent; // They may have a parrent.

list<Configurator*> myStartConfigurators; // Call these when we start Interpret()
list<Configurator*> myEndConfigurators; // Call these when we finish Interpret()
std::list<Configurator*> myStartConfigurators; // Call these when we start Interpret()
std::list<Configurator*> myEndConfigurators; // Call these when we finish Interpret()

// Internal / subordinate things I own and kill...

list<ConfigurationAttribute*> myAttributes; // They may have a list of attributes.
list<ConfigurationElement*> myElements; // They may have a list of sub-elements.
list<ConfigurationMnemonic*> myMnemonics; // They may have a list of mnemonics.
list<ConfigurationTranslator*> myTranslators; // They may have a list of translators.
std::list<ConfigurationAttribute*> myAttributes; // They may have a list of attributes.
std::list<ConfigurationElement*> myElements; // They may have a list of sub-elements.
std::list<ConfigurationMnemonic*> myMnemonics; // They may have a list of mnemonics.
std::list<ConfigurationTranslator*> myTranslators; // They may have a list of translators.

// During Interpret() operations we keep track of where we are seen...

@@ -166,10 +166,10 @@ class ConfigurationElement {
public:

ConfigurationElement(const char* Name); // Must be constructed with a name
ConfigurationElement(const string Name); // either c string or c++ string.
ConfigurationElement(const std::string Name); // either c string or c++ string.

ConfigurationElement(const char* Name, ConfigurationElement& Parent); // Sub-elements are constructed with a
ConfigurationElement(const string Name, ConfigurationElement& Parent); // parrent.
ConfigurationElement(const std::string Name, ConfigurationElement& Parent); // parrent.

// Upon desctruction an element will delete all subordinate objects:
// * All sub element objects.
@@ -188,7 +188,7 @@ class ConfigurationElement {

// Elements can be probed for some simple, useful things.

string Name(); // Get the name of this element.
std::string Name(); // Get the name of this element.
ConfigurationElement& Parent(); // Get the parent of this element.
ConfigurationElement& Parent(ConfigurationElement& newParent); // Set the parent of this element.

@@ -202,7 +202,7 @@ class ConfigurationElement {
// Elements can contain either data or sub-elements.

ConfigurationElement& Element(const char* Name); // Add a new sub element by c string name.
ConfigurationElement& Element(const string Name); // Add a new sub element by c++ string name.
ConfigurationElement& Element(const std::string Name); // Add a new sub element by c++ string name.

//// Mapping element factory methods for convenience.
//// Root-Node elements are _usually_ empty and without attributes in xml
@@ -216,7 +216,7 @@ class ConfigurationElement {

ConfigurationElement& Element( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
string& x, string init = string("")); // Map to a string.
std::string& x, std::string init = std::string("")); // Map to a string.

ConfigurationElement& Element( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
@@ -233,23 +233,23 @@ class ConfigurationElement {
// string versions

ConfigurationElement& Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
ConfigurationTranslator& newTranslator); // Add a Translator to this element.

ConfigurationElement& Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
string& x, string init = string("")); // Map to a string.
const std::string Name, // requires a name, of course,
std::string& x, std::string init = std::string("")); // Map to a string.

ConfigurationElement& Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
int& x, int init = 0, int radix = 0); // Map to an int.

ConfigurationElement& Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
double& x, double init = 0.0); // Map to a double.

ConfigurationElement& Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
bool& x, bool init = false); // Map to a boolean.

// End methods for heading back up the tree at the end of an element.
@@ -258,12 +258,12 @@ class ConfigurationElement {

ConfigurationElement& End(); // Return this element's parent.
ConfigurationElement& End(const char* Name); // Check the name and return the parent
ConfigurationElement& End(const string Name); // if the name is correct - or throw!
ConfigurationElement& End(const std::string Name); // if the name is correct - or throw!

// Elements can have attributes.

ConfigurationAttribute& Attribute(const char* Name); // Add an attribute using a cstring.
ConfigurationAttribute& Attribute(const string Name); // Add an attribute using a c++ string.
ConfigurationAttribute& Attribute(const std::string Name); // Add an attribute using a c++ string.

//// Mapping Attribute factory methods for convenience.

@@ -275,7 +275,7 @@ class ConfigurationElement {

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
string& x, string init = string("")); // Map to a string.
std::string& x, std::string init = std::string("")); // Map to a string.

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
@@ -292,23 +292,23 @@ class ConfigurationElement {
// string versions

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
ConfigurationTranslator& newTranslator); // Add a Translator to this element.

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
string& x, string init = string("")); // Map to a string.
const std::string Name, // requires a name, of course,
std::string& x, std::string init = std::string("")); // Map to a string.

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
int& x, int init = 0, int radix = 0); // Map to an int.

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
double& x, double init = 0.0); // Map to a double.

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
bool& x, bool init = false); // Map to a boolean.

// Elements can Initialize() at each Interpret() call.
@@ -330,7 +330,7 @@ class ConfigurationElement {
// to the converted value. Usually - just one variable.

ConfigurationElement& mapTo(ConfigurationTranslator& newTranslator); // Add a Translator to this element.
ConfigurationElement& mapTo(string& x, string init = string("")); // Map to a string.
ConfigurationElement& mapTo(std::string& x, std::string init = std::string("")); // Map to a string.
ConfigurationElement& mapTo(int& x, int init = 0, int radix = 0); // Map to an int.
ConfigurationElement& mapTo(double& x, double init = 0.0); // Map to a double.
ConfigurationElement& mapTo(bool& x, bool init = false); // Map to a boolean.
@@ -341,9 +341,9 @@ class ConfigurationElement {
// passed to the Translators instead of the raw contents.

ConfigurationElement& Mnemonic(const char* name, const char* value); // Add a mnemonic using c strings.
ConfigurationElement& Mnemonic(const char* name, const string value); // Add a mnemonic using c & c++ strings.
ConfigurationElement& Mnemonic(const string name, const char* value); // Add a mnemonic using c++ & c strings.
ConfigurationElement& Mnemonic(const string name, const string value); // Add a mnemonic using c++ strings.
ConfigurationElement& Mnemonic(const char* name, const std::string value); // Add a mnemonic using c & c++ strings.
ConfigurationElement& Mnemonic(const std::string name, const char* value); // Add a mnemonic using c++ & c strings.
ConfigurationElement& Mnemonic(const std::string name, const std::string value); // Add a mnemonic using c++ strings.

// The way data gets into an element tree is that it is Interpret()ed
// recursively. The data is loaded into a ConfigurationData object which
@@ -387,11 +387,11 @@ class ConfigurationAttribute {

private:

string myName; // Elements have a name.
std::string myName; // Elements have a name.
ConfigurationElement& myParent; // They may have a parrent.

list<ConfigurationMnemonic*> myMnemonics; // They may have a list of mnemonics.
list<ConfigurationTranslator*> myTranslators; // They may have a list of translators.
std::list<ConfigurationMnemonic*> myMnemonics; // They may have a list of mnemonics.
std::list<ConfigurationTranslator*> myTranslators; // They may have a list of translators.

int myLine; // Last line number I was seen on.
int myIndex; // Last char position I was seen on.
@@ -400,7 +400,7 @@ class ConfigurationAttribute {
public:

ConfigurationAttribute(const char* Name, ConfigurationElement& Parent); // Sub-elements are constructed with a
ConfigurationAttribute(const string Name, ConfigurationElement& Parent); // parrent.
ConfigurationAttribute(const std::string Name, ConfigurationElement& Parent); // parrent.

// Attributes delete their Mnemonics and Translators when they go.
// See Elements for similar warnings about objects provided to
@@ -411,7 +411,7 @@ class ConfigurationAttribute {

// Attributes can be probed for some simple, useful things.

string Name(); // Get the name of this attribute.
std::string Name(); // Get the name of this attribute.
ConfigurationElement& Parent(); // Get the parent of this attribute.
int Line(); // Get the last line number.
int Index(); // Get the last data position.
@@ -427,7 +427,7 @@ class ConfigurationAttribute {
//// For switching back to the parent element and adding new sub-elements.

ConfigurationElement& Element(const char* Name); // Add a new sub element by c string name.
ConfigurationElement& Element(const string Name); // Add a new sub element by c++ string name.
ConfigurationElement& Element(const std::string Name); // Add a new sub element by c++ string name.

//// Mapping element factory methods for convenience.
//// Root-Node elements are _usually_ empty and without attributes in xml
@@ -441,7 +441,7 @@ class ConfigurationAttribute {

ConfigurationElement& Element( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
string& x, string init = string("")); // Map to a string.
std::string& x, std::string init = std::string("")); // Map to a string.

ConfigurationElement& Element( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
@@ -458,35 +458,35 @@ class ConfigurationAttribute {
// string versions

ConfigurationElement& Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
ConfigurationTranslator& newTranslator); // Add a Translator to this element.

ConfigurationElement& Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
string& x, string init = string("")); // Map to a string.
const std::string Name, // requires a name, of course,
std::string& x, std::string init = std::string("")); // Map to a string.

ConfigurationElement& Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
int& x, int init = 0, int radix = 0); // Map to an int.

ConfigurationElement& Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
double& x, double init = 0.0); // Map to a double.

ConfigurationElement& Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
bool& x, bool init = false); // Map to a boolean.

// End methods for heading back up the tree at the end of an element.

ConfigurationElement& End(); // Return this element's parent.
ConfigurationElement& End(const char* Name); // Check the name and return the parent
ConfigurationElement& End(const string Name); // if the name is correct - or throw!
ConfigurationElement& End(const std::string Name); // if the name is correct - or throw!

//// For adding new attributes to the parent element.

ConfigurationAttribute& Attribute(const char* Name); // Add an attribute using a cstring.
ConfigurationAttribute& Attribute(const string Name); // Add an attribute using a c++ string.
ConfigurationAttribute& Attribute(const std::string Name); // Add an attribute using a c++ string.

//// Mapping Attribute factory methods for convenience.

@@ -498,7 +498,7 @@ class ConfigurationAttribute {

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
string& x, string init = string("")); // Map to a string.
std::string& x, std::string init = std::string("")); // Map to a string.

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
@@ -515,23 +515,23 @@ class ConfigurationAttribute {
// string versions

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
ConfigurationTranslator& newTranslator); // Add a Translator to this element.

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
string& x, string init = string("")); // Map to a string.
const std::string Name, // requires a name, of course,
std::string& x, std::string init = std::string("")); // Map to a string.

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
int& x, int init = 0, int radix = 0); // Map to an int.

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
double& x, double init = 0.0); // Map to a double.

ConfigurationAttribute& Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
bool& x, bool init = false); // Map to a boolean.

//// Set Init On Interprete for the parent element.
@@ -549,7 +549,7 @@ class ConfigurationAttribute {
// attribute.

ConfigurationAttribute& mapTo(ConfigurationTranslator& newTranslator); // Add a Translator to this attribute.
ConfigurationAttribute& mapTo(string& x, string init = string("")); // Map to a string.
ConfigurationAttribute& mapTo(std::string& x, std::string init = std::string("")); // Map to a string.
ConfigurationAttribute& mapTo(int& x, int init, int radix = 0); // Map to an int.
ConfigurationAttribute& mapTo(double& x, double init = 0.0); // Map to a double.
ConfigurationAttribute& mapTo(bool& x, bool init = false); // Map to a boolean.
@@ -557,9 +557,9 @@ class ConfigurationAttribute {
// Attributes can have mnemonics just like elements.

ConfigurationAttribute& Mnemonic(const char* name, const char* value); // Add a mnemonic using a c string.
ConfigurationAttribute& Mnemonic(const char* name, const string value); // Add a mnemonic using c & c++ strings.
ConfigurationAttribute& Mnemonic(const string name, const char* value); // Add a mnemonic using c++ & c strings.
ConfigurationAttribute& Mnemonic(const string name, const string value); // Add a mnemonic using a c++ string.
ConfigurationAttribute& Mnemonic(const char* name, const std::string value);// Add a mnemonic using c & c++ strings.
ConfigurationAttribute& Mnemonic(const std::string name, const char* value);// Add a mnemonic using c++ & c strings.
ConfigurationAttribute& Mnemonic(const std::string name, const std::string value); // Add a mnemonic using a c++ string.

// Attributes participate in the Interprete() task just like elements.

@@ -587,7 +587,7 @@ class ConfigurationData {
public:

ConfigurationData(const char* FileName); // Constructor from c string file name.
ConfigurationData(const string FileName); // Constructor from c++ string file name.
ConfigurationData(const std::string FileName); // Constructor from c++ string file name.
ConfigurationData(const char* Data, int Length); // Raw constructor from text buffer.

~ConfigurationData(); // Destroys the internal buffer etc.
@@ -598,7 +598,7 @@ class ConfigurationData {
int Line(); // Reads the current Line number.
int addNewLines(int Count); // Increments the Line number.

stringstream Log; // Convenient Interpret log.
std::stringstream Log; // Convenient Interpret log.

};

@@ -617,13 +617,13 @@ class ConfigurationTranslator {

class StringTranslator : public ConfigurationTranslator {
private:
string& myVariable; // Variable to map.
string myInitializer; // Initial/Default value.
std::string& myVariable; // Variable to map.
std::string myInitializer; // Initial/Default value.

public:
StringTranslator( // Construct this with
string& Variable, // the variable to map,
string Inititializer); // and the default value.
std::string& Variable, // the variable to map,
std::string Inititializer); // and the default value.

void translate(const char* Value); // Provide a translation method.
void initialize(); // Provide an initialization method.
@@ -684,13 +684,13 @@ class BoolTranslator : public ConfigurationTranslator {

class ConfigurationMnemonic { // Mnemonics
private:
string myName; // What is the Mnemonic?
string myValue; // What is the translation?
std::string myName; // What is the Mnemonic?
std::string myValue; // What is the translation?

public:
ConfigurationMnemonic(string Name, string Value); // To make one, provide both parts.
bool test(string Name); // Test to see if this Mnemonic matches.
string Value(); // If it does then we will need it's value.
ConfigurationMnemonic(std::string Name, std::string Value); // To make one, provide both parts.
bool test(std::string Name); // Test to see if this Mnemonic matches.
std::string Value(); // If it does then we will need it's value.
};

//// Configurator //////////////////////////////////////////////////////////////
@@ -728,6 +728,7 @@ class ConfiguratorSetTrueOnComplete : public Configurator {
void operator()(ConfigurationElement& E, ConfigurationData& D); // Handle the operation.
};

}
#endif

// End Of Include Only Once

+ 60
- 60
configuration.inline.hpp Переглянути файл

@@ -24,7 +24,7 @@
//// Configuration Element /////////////////////////////////////////////////////

inline ConfigurationElement::ConfigurationElement(const char* Name) : // Construct with a cstring.
myName(string(Name)),
myName(std::string(Name)),
myParent(NULL),
myLine(0),
myIndex(0),
@@ -33,7 +33,7 @@ inline ConfigurationElement::ConfigurationElement(const char* Name) :
myInitOnInterpretFlag(false) {
}

inline ConfigurationElement::ConfigurationElement(const string Name) : // Construct with a c++ string.
inline ConfigurationElement::ConfigurationElement(const std::string Name) : // Construct with a c++ string.
myName(Name),
myParent(NULL),
myLine(0),
@@ -47,7 +47,7 @@ inline ConfigurationElement::ConfigurationElement(
const char* Name,
ConfigurationElement& Parent) :

myName(string(Name)),
myName(std::string(Name)),
myParent(&Parent),
myLine(0),
myIndex(0),
@@ -57,7 +57,7 @@ inline ConfigurationElement::ConfigurationElement(
}

inline ConfigurationElement::ConfigurationElement( // Construct sub element w/ string.
const string Name,
const std::string Name,
ConfigurationElement& Parent) :

myName(Name),
@@ -69,7 +69,7 @@ inline ConfigurationElement::ConfigurationElement(
myInitOnInterpretFlag(false) {
}

inline string ConfigurationElement::Name() { return myName; } // Get the name of this element.
inline std::string ConfigurationElement::Name() { return myName; } // Get the name of this element.

inline ConfigurationElement& ConfigurationElement::Parent() { // Get the parrent of this element.
if(NULL != myParent) { // If I have a parent
@@ -93,10 +93,10 @@ inline int ConfigurationElement::Length() { return myLength; }
inline void ConfigurationElement::notifyDirty() { myCleanFlag = false; } // Attributes do this when they change.

inline ConfigurationElement& ConfigurationElement::Element(const char* Name) { // Add a new sub element by c string name.
return Element(string(Name)); // Use the string name version
return Element(std::string(Name)); // Use the string name version
}

inline ConfigurationElement& ConfigurationElement::Element(const string Name) { // Add a new sub element by c++ string name.
inline ConfigurationElement& ConfigurationElement::Element(const std::string Name) { // Add a new sub element by c++ string name.
ConfigurationElement* N = new ConfigurationElement( // Create a new Element with the
Name, // name provided and
(*this)); // myself as the parent.
@@ -108,31 +108,31 @@ inline ConfigurationElement& ConfigurationElement::Element(const string Name) {
inline ConfigurationElement& ConfigurationElement::Element( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
ConfigurationTranslator& newTranslator) { // Add a Translator to this element.
return Element(string(Name), newTranslator); // Use the string name version
return Element(std::string(Name), newTranslator); // Use the string name version
}

inline ConfigurationElement& ConfigurationElement::Element( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
string& x, string init) { // Map to a string.
return Element(string(Name), x, init); // Use the string name version
std::string& x, std::string init) { // Map to a string.
return Element(std::string(Name), x, init); // Use the string name version
}

inline ConfigurationElement& ConfigurationElement::Element( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
int& x, int init, int radix) { // Map to an int.
return Element(string(Name), x, init, radix); // Use the string name version
return Element(std::string(Name), x, init, radix); // Use the string name version
}

inline ConfigurationElement& ConfigurationElement::Element( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
double& x, double init) { // Map to a double.
return Element(string(Name), x, init); // Use the string name version
return Element(std::string(Name), x, init); // Use the string name version
}

inline ConfigurationElement& ConfigurationElement::Element( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
bool& x, bool init) { // Map to a boolean.
return Element(string(Name), x, init); // Use the string name version
return Element(std::string(Name), x, init); // Use the string name version
}

inline ConfigurationElement& ConfigurationElement::End() { // Return this element's parent.
@@ -140,10 +140,10 @@ inline ConfigurationElement& ConfigurationElement::End() {
}

inline ConfigurationElement& ConfigurationElement::End(const char* Name) { // Check the name and return the parent
return End(string(Name)); // Borrow End(string)
return End(std::string(Name)); // Borrow End(string)
}

inline ConfigurationElement& ConfigurationElement::End(const string Name) { // if the name is correct - or throw!
inline ConfigurationElement& ConfigurationElement::End(const std::string Name) {// if the name is correct - or throw!
if(0 != Name.compare(myName)) { // If Name is not myName
throw EndNameDoesNotMatch(); // throw an exception!
} // If the names match then
@@ -152,37 +152,37 @@ inline ConfigurationElement& ConfigurationElement::End(const string Name) {

inline ConfigurationAttribute& ConfigurationElement::Attribute( // Add an attribute using a cstring.
const char* Name) { // Given this cstring name
return Attribute(string(Name)); // Convert it to a string and borrow
return Attribute(std::string(Name)); // Convert it to a string and borrow
} // Attribute(string)

inline ConfigurationAttribute& ConfigurationElement::Attribute( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
ConfigurationTranslator& newTranslator) { // Add a Translator to this element.
return Attribute(string(Name), newTranslator); // Borrow the string name version
return Attribute(std::string(Name), newTranslator); // Borrow the string name version
}

inline ConfigurationAttribute& ConfigurationElement::Attribute( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
string& x, string init) { // Map to a string.
return Attribute(string(Name), x, init); // Borrow the string name version
std::string& x, std::string init) { // Map to a string.
return Attribute(std::string(Name), x, init); // Borrow the string name version
}

inline ConfigurationAttribute& ConfigurationElement::Attribute( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
int& x, int init, int radix) { // Map to an int.
return Attribute(string(Name), x, init); // Borrow the string name version
return Attribute(std::string(Name), x, init); // Borrow the string name version
}

inline ConfigurationAttribute& ConfigurationElement::Attribute( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
double& x, double init) { // Map to a double.
return Attribute(string(Name), x, init); // Borrow the string name version
return Attribute(std::string(Name), x, init); // Borrow the string name version
}

inline ConfigurationAttribute& ConfigurationElement::Attribute( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
bool& x, bool init) { // Map to a boolean.
return Attribute(string(Name), x, init); // Borrow the string name version
return Attribute(std::string(Name), x, init); // Borrow the string name version
}

inline ConfigurationElement& ConfigurationElement::setInitOnInterpret() { // Set the init on interpret flag.
@@ -204,21 +204,21 @@ inline ConfigurationElement& ConfigurationElement::atEndCall(

inline ConfigurationElement& ConfigurationElement::Mnemonic( // Add a mnemonic using c strings.
const char* name, const char* value) { // Given char* and char*
return Mnemonic(string(name), string(value)); // make strings and borrow that method.
return Mnemonic(std::string(name), std::string(value)); // make strings and borrow that method.
}

inline ConfigurationElement& ConfigurationElement::Mnemonic( // Add a mnemonic using mixed strings.
const char* name, const string value) { // Given char* and string
return Mnemonic(string(name), value); // make strings and borrow that method.
const char* name, const std::string value) { // Given char* and string
return Mnemonic(std::string(name), value); // make strings and borrow that method.
}

inline ConfigurationElement& ConfigurationElement::Mnemonic( // Add a mnemonic using mixed strings.
const string name, const char* value) { // Given string and char*
return Mnemonic(name, string(value)); // make strings and borrow that method.
const std::string name, const char* value) { // Given string and char*
return Mnemonic(name, std::string(value)); // make strings and borrow that method.
}

inline ConfigurationElement& ConfigurationElement::Mnemonic( // Add a mnemonic using c++ strings.
const string name, const string value) { // Givent string and string
const std::string name, const std::string value) { // Givent string and string
ConfigurationMnemonic* N = // Create a new Mnemonic
new ConfigurationMnemonic(name, value); // using the values provided,
myMnemonics.push_back(N); // add it to my list, then
@@ -229,7 +229,7 @@ inline ConfigurationElement& ConfigurationElement::Mnemonic(

inline ConfigurationAttribute::ConfigurationAttribute( // Attributes are constructed with a
const char* Name, ConfigurationElement& Parent) : // Name and a Parent.
myName(string(Name)), // We convert the name to a string.
myName(std::string(Name)), // We convert the name to a string.
myParent(Parent), // We just grab the parent.
myLine(0), // Everything else gets zeroed.
myIndex(0),
@@ -237,7 +237,7 @@ inline ConfigurationAttribute::ConfigurationAttribute(
}

inline ConfigurationAttribute::ConfigurationAttribute( // Attributes are constrictued with a
const string Name, ConfigurationElement& Parent) : // Name and a Parent.
const std::string Name, ConfigurationElement& Parent) : // Name and a Parent.
myName(Name), // We grab them and zero the rest.
myParent(Parent),
myLine(0),
@@ -245,7 +245,7 @@ inline ConfigurationAttribute::ConfigurationAttribute(
myLength(0) {
}

inline string ConfigurationAttribute::Name() { // Get the name of this attribute.
inline std::string ConfigurationAttribute::Name() { // Get the name of this attribute.
return myName;
}

@@ -271,7 +271,7 @@ inline ConfigurationElement& ConfigurationAttribute::Element(
}

inline ConfigurationElement& ConfigurationAttribute::Element( // Add a new sub element by c++ string name.
const string Name) {
const std::string Name) {
return myParent.Element(Name);
}

@@ -283,7 +283,7 @@ inline ConfigurationElement& ConfigurationAttribute::Element(

inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
string& x, string init) { // Map to a string.
std::string& x, std::string init) { // Map to a string.
return myParent.Element(Name, x, init);
}

@@ -306,31 +306,31 @@ inline ConfigurationElement& ConfigurationAttribute::Element(
}

inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
ConfigurationTranslator& newTranslator) { // Add a Translator to this element.
return myParent.Element(Name, newTranslator);
}

inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
string& x, string init) { // Map to a string.
const std::string Name, // requires a name, of course,
std::string& x, std::string init) { // Map to a string.
return myParent.Element(Name, x, init);
}

inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
int& x, int init, int radix) { // Map to an int.
return myParent.Element(Name, x, init, radix);
}

inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
double& x, double init) { // Map to a double.
return myParent.Element(Name, x, init);
}

inline ConfigurationElement& ConfigurationAttribute::Element( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
bool& x, bool init) { // Map to a boolean.
return myParent.Element(Name, x, init);
}
@@ -343,7 +343,7 @@ inline ConfigurationElement& ConfigurationAttribute::End(const char* Name) {
return myParent.End(Name);
}

inline ConfigurationElement& ConfigurationAttribute::End(const string Name) { // if the name is correct - or throw!
inline ConfigurationElement& ConfigurationAttribute::End(const std::string Name) { // if the name is correct - or throw!
return myParent.End(Name);
}

@@ -353,7 +353,7 @@ inline ConfigurationAttribute& ConfigurationAttribute::Attribute(
}

inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Add an attribute using a c++ string.
const string Name) {
const std::string Name) {
return myParent.Attribute(Name);
}

@@ -365,7 +365,7 @@ inline ConfigurationAttribute& ConfigurationAttribute::Attribute(

inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
const char* Name, // requires a name, of course,
string& x, string init) { // Map to a string.
std::string& x, std::string init) { // Map to a string.
return myParent.Attribute(Name, x, init);
}

@@ -388,31 +388,31 @@ inline ConfigurationAttribute& ConfigurationAttribute::Attribute(
}

inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
ConfigurationTranslator& newTranslator) { // Add a Translator to this element.
return myParent.Attribute(Name, newTranslator);
}

inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
string& x, string init) { // Map to a string.
const std::string Name, // requires a name, of course,
std::string& x, std::string init) { // Map to a string.
return myParent.Attribute(Name, x, init);
}

inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
int& x, int init, int radix) { // Map to an int.
return myParent.Attribute(Name, x, init, radix);
}

inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
double& x, double init) { // Map to a double.
return myParent.Attribute(Name, x, init);
}

inline ConfigurationAttribute& ConfigurationAttribute::Attribute( // Mapping factory for convenience,
const string Name, // requires a name, of course,
const std::string Name, // requires a name, of course,
bool& x, bool init) { // Map to a boolean.
return myParent.Attribute(Name, x, init);
}
@@ -433,21 +433,21 @@ inline ConfigurationElement& ConfigurationAttribute::atEndCall(

inline ConfigurationAttribute& ConfigurationAttribute::Mnemonic( // Add a mnemonic using c strings.
const char* name, const char* value) { // Given char* and char*
return Mnemonic(string(name), string(value)); // make strings and borrow that method.
return Mnemonic(std::string(name), std::string(value)); // make strings and borrow that method.
}

inline ConfigurationAttribute& ConfigurationAttribute::Mnemonic( // Add a mnemonic using mixed strings.
const char* name, const string value) { // Given char* and string
return Mnemonic(string(name), value); // make strings and borrow that method.
const char* name, const std::string value) { // Given char* and string
return Mnemonic(std::string(name), value); // make strings and borrow that method.
}

inline ConfigurationAttribute& ConfigurationAttribute::Mnemonic( // Add a mnemonic using mixed strings.
const string name, const char* value) { // Given string and char*
return Mnemonic(name, string(value)); // make strings and borrow that method.
const std::string name, const char* value) { // Given string and char*
return Mnemonic(name, std::string(value)); // make strings and borrow that method.
}

inline ConfigurationAttribute& ConfigurationAttribute::Mnemonic( // Add a mnemonic using c++ strings.
const string name, const string value) { // Givent string and string
const std::string name, const std::string value) { // Givent string and string
ConfigurationMnemonic* N = // Create a new Mnemonic
new ConfigurationMnemonic(name, value); // using the values provided,
myMnemonics.push_back(N); // add it to my list, then
@@ -487,14 +487,14 @@ inline int ConfigurationData::addNewLines(int Count) {
//// Configuration Translator //////////////////////////////////////////////////

inline StringTranslator::StringTranslator( // Construct this with
string& Variable, // the variable to map,
string Initializer) : // and the default value.
std::string& Variable, // the variable to map,
std::string Initializer) : // and the default value.
myVariable(Variable),
myInitializer(Initializer) {
}

inline void StringTranslator::translate(const char* Value) { // Provide a translation method.
myVariable = string(Value); // String to String = simple copy.
myVariable = std::string(Value); // String to String = simple copy.
}

inline void StringTranslator::initialize() { // Provide an initialization method.
@@ -562,15 +562,15 @@ inline void BoolTranslator::initialize() {
//// Configuration Mnemonic ////////////////////////////////////////////////////

inline ConfigurationMnemonic::ConfigurationMnemonic( // To make one, provide both parts.
string Name, string Value) :
std::string Name, std::string Value) :
myName(Name),
myValue(Value) {
}

inline bool ConfigurationMnemonic::test(string Name) { // Test to see if this Mnemonic matches.
inline bool ConfigurationMnemonic::test(std::string Name) { // Test to see if this Mnemonic matches.
return (0 == Name.compare(myName)); // Return true if Name and myName match.
}

inline string ConfigurationMnemonic::Value() { // If it does then we will need it's value.
inline std::string ConfigurationMnemonic::Value() { // If it does then we will need it's value.
return myValue;
}

Завантаження…
Відмінити
Зберегти