Browse Source

refactor: function_name to functionName in data.h (functions on isc::data::Elements)

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@408 e5f2f494-b856-4b98-b285-d166d9295462
Jelte Jansen 15 years ago
parent
commit
138c18e70a

+ 5 - 5
src/bin/parkinglot/ccsession.cc

@@ -100,12 +100,12 @@ CommandSession::CommandSession(std::string module_name,
     
     // get any stored configuration from the manager
     if (config_handler_) {
-        ElementPtr cmd = Element::create_from_string("{ \"command\": [ \"get_config\", \"" + module_name + "\" ] }");
+        ElementPtr cmd = Element::createFromString("{ \"command\": [ \"get_config\", \"" + module_name + "\" ] }");
         session_.group_sendmsg(cmd, "ConfigManager");
         session_.group_recvmsg(env, answer, false);
         cout << "[XX] got config: " << endl << answer->str() << endl;
         if (answer->contains("result") &&
-            answer->get("result")->get(0)->int_value() == 0 &&
+            answer->get("result")->get(0)->intValue() == 0 &&
             answer->get("result")->size() > 1) {
             config_handler(answer->get("result")->get(1));
         } else {
@@ -128,7 +128,7 @@ CommandSession::check_command()
     if (session_.group_recvmsg(routing, data, true)) {
         /* ignore result messages (in case we're out of sync, to prevent
          * pingpongs */
-        if (!data->get_type() == Element::map || data->contains("result")) {
+        if (!data->getType() == Element::map || data->contains("result")) {
             return 0;
         }
         cout << "[XX] got something!" << endl << data->str() << endl;
@@ -138,14 +138,14 @@ CommandSession::check_command()
                 // handle config update
                 answer = config_handler_(data->get("config_update"));
             } else {
-                answer = Element::create_from_string("{ \"result\": [0] }");
+                answer = Element::createFromString("{ \"result\": [0] }");
             }
         }
         if (data->contains("command")) {
             if (command_handler_) {
                 answer = command_handler_(data->get("command"));
             } else {
-                answer = Element::create_from_string("{ \"result\": [0] }");
+                answer = Element::createFromString("{ \"result\": [0] }");
             }
         }
         session_.reply(routing, answer);

+ 12 - 12
src/bin/parkinglot/main.cc

@@ -64,8 +64,8 @@ my_config_handler(isc::data::ElementPtr config)
     cout << "[XX] Handle config: " << endl << config->str() << endl;
     if (config->contains("zones")) {
         plot.clear_zones();
-        BOOST_FOREACH(isc::data::ElementPtr zone_el, config->get("zones")->list_value()) {
-            plot.serve(zone_el->string_value());
+        BOOST_FOREACH(isc::data::ElementPtr zone_el, config->get("zones")->listValue()) {
+            plot.serve(zone_el->stringValue());
         }
     }
     if (config->contains("port")) {
@@ -74,33 +74,33 @@ my_config_handler(isc::data::ElementPtr config)
     }
     if (config->contains("a_records")) {
         plot.clearARecords();
-        BOOST_FOREACH(isc::data::ElementPtr rel, config->get("a_records")->list_value()) {
-            plot.addARecord(rel->string_value());
+        BOOST_FOREACH(isc::data::ElementPtr rel, config->get("a_records")->listValue()) {
+            plot.addARecord(rel->stringValue());
         }
     }
     if (config->contains("aaaa_records")) {
         plot.clearAAAARecords();
-        BOOST_FOREACH(isc::data::ElementPtr rel, config->get("aaaa_records")->list_value()) {
-            plot.addAAAARecord(rel->string_value());
+        BOOST_FOREACH(isc::data::ElementPtr rel, config->get("aaaa_records")->listValue()) {
+            plot.addAAAARecord(rel->stringValue());
         }
     }
     if (config->contains("ns_records")) {
         plot.clearNSRecords();
-        BOOST_FOREACH(isc::data::ElementPtr rel, config->get("ns_records")->list_value()) {
-            plot.addNSRecord(rel->string_value());
+        BOOST_FOREACH(isc::data::ElementPtr rel, config->get("ns_records")->listValue()) {
+            plot.addNSRecord(rel->stringValue());
         }
     }
-    return isc::data::Element::create_from_string("{ \"result\": [0] }");
+    return isc::data::Element::createFromString("{ \"result\": [0] }");
 }
 
 isc::data::ElementPtr
 my_command_handler(isc::data::ElementPtr command)
 {
-    isc::data::ElementPtr answer = isc::data::Element::create_from_string("{ \"result\": [0] }");
+    isc::data::ElementPtr answer = isc::data::Element::createFromString("{ \"result\": [0] }");
 
     cout << "[XX] Handle command: " << endl << command->str() << endl;
-    if (command->get(1)->string_value() == "print_message") {
-        cout << command->get(2)->string_value() << endl;
+    if (command->get(1)->stringValue() == "print_message") {
+        cout << command->get(2)->stringValue() << endl;
         /* let's add that message to our answer as well */
         cout << "[XX] answer was: " << answer->str() << endl;
         answer->get("result")->add(command->get(2));

+ 2 - 2
src/bin/parkinglot/parkinglot.cc

@@ -235,8 +235,8 @@ ParkingLot::command(pair<string,ElementPtr> cmd) {
         // We could walk through both lists and remove and serve
         // accordingly, or simply clear all and add everything
         zones.clear_zones();
-        BOOST_FOREACH(ElementPtr zone, zonelist_el->list_value()) {
-            zones.serve(zone->string_value());
+        BOOST_FOREACH(ElementPtr zone, zonelist_el->listValue()) {
+            zones.serve(zone->stringValue());
         }
     }
 }

+ 43 - 43
src/lib/cc/cpp/data.cc

@@ -104,7 +104,7 @@ Element::create(const std::map<std::string, ElementPtr>& m)
 
 
 //
-// helper functions for create_from_string factory
+// helper functions for createFromString factory
 // these should probably also be moved to member functions
 //
 
@@ -268,7 +268,7 @@ from_stringstream_list(std::istream &in, int& line, int& pos)
     while (c != EOF && c != ']') {
         //cout << "at line " << line << " pos " << pos << " cur c: " << c << " next c: " << char(in.peek()) << endl;
         if (in.peek() != ']') {
-            cur_list_element = Element::create_from_string(in, line, pos);
+            cur_list_element = Element::createFromString(in, line, pos);
             v.push_back(cur_list_element);
             skip_to(in, line, pos, ",]", " \t\n");
         }
@@ -293,7 +293,7 @@ from_stringstream_map(std::istream &in, int& line, int& pos)
         // skip the :
         in.get();
         pos++;
-        p.second = Element::create_from_string(in, line, pos);
+        p.second = Element::createFromString(in, line, pos);
         if (!p.second) {
             throw ParseError(std::string("missing map value for ") + p.first, line, pos);
         };
@@ -306,14 +306,14 @@ from_stringstream_map(std::istream &in, int& line, int& pos)
 }
 
 ElementPtr
-Element::create_from_string(std::istream &in) throw(ParseError)
+Element::createFromString(std::istream &in) throw(ParseError)
 {
     int line = 1, pos = 1;
-    return create_from_string(in, line, pos);
+    return createFromString(in, line, pos);
 }
 
 ElementPtr
-Element::create_from_string(std::istream &in, int& line, int& pos) throw(ParseError)
+Element::createFromString(std::istream &in, int& line, int& pos) throw(ParseError)
 {
     char c = 0;
     ElementPtr element;
@@ -374,11 +374,11 @@ Element::create_from_string(std::istream &in, int& line, int& pos) throw(ParseEr
 }
 
 ElementPtr
-Element::create_from_string(const std::string &in)
+Element::createFromString(const std::string &in)
 {
     std::stringstream ss;
     ss << in;
-    return create_from_string(ss);
+    return createFromString(ss);
 }
 //
 // a general to_str() function
@@ -387,7 +387,7 @@ std::string
 IntElement::str()
 {
     std::stringstream ss;
-    ss << int_value();
+    ss << intValue();
     return ss.str();
 }
 
@@ -395,7 +395,7 @@ std::string
 DoubleElement::str()
 {
     std::stringstream ss;
-    ss << double_value();
+    ss << doubleValue();
     return ss.str();
 }
 
@@ -414,7 +414,7 @@ StringElement::str()
 {
     std::stringstream ss;
     ss << "\"";
-    ss << string_value();
+    ss << stringValue();
     ss << "\"";
     return ss.str();
 }
@@ -425,7 +425,7 @@ ListElement::str()
     std::stringstream ss;
     std::vector<ElementPtr> v;
     ss << "[ ";
-    v = list_value();
+    v = listValue();
     for (std::vector<ElementPtr>::iterator it = v.begin(); it != v.end(); ++it) {
         if (it != v.begin()) {
             ss << ", ";
@@ -442,7 +442,7 @@ MapElement::str()
     std::stringstream ss;
     std::map<std::string, ElementPtr> m;
     ss << "{";
-    m = map_value();
+    m = mapValue();
     for (std::map<std::string, ElementPtr>::iterator it = m.begin(); it != m.end(); ++it) {
         if (it != m.begin()) {
             ss << ", ";
@@ -455,7 +455,7 @@ MapElement::str()
 }
 
 //
-// helpers for str_xml() functions
+// helpers for strXML() functions
 //
 
 // prefix with 'prefix' number of spaces
@@ -468,7 +468,7 @@ pre(std::ostream &out, size_t prefix)
 }
 
 std::string
-IntElement::str_xml(size_t prefix)
+IntElement::strXML(size_t prefix)
 {
     std::stringstream ss;
     pre(ss, prefix);
@@ -477,7 +477,7 @@ IntElement::str_xml(size_t prefix)
 }
 
 std::string
-DoubleElement::str_xml(size_t prefix)
+DoubleElement::strXML(size_t prefix)
 {
     std::stringstream ss;
     pre(ss, prefix);
@@ -486,7 +486,7 @@ DoubleElement::str_xml(size_t prefix)
 }
 
 std::string
-BoolElement::str_xml(size_t prefix)
+BoolElement::strXML(size_t prefix)
 {
     std::stringstream ss;
     pre(ss, prefix);
@@ -495,26 +495,26 @@ BoolElement::str_xml(size_t prefix)
 }
 
 std::string
-StringElement::str_xml(size_t prefix)
+StringElement::strXML(size_t prefix)
 {
     std::stringstream ss;
     pre(ss, prefix);
-    ss << string_value();
+    ss << stringValue();
     return ss.str();
 }
 
 std::string
-ListElement::str_xml(size_t prefix)
+ListElement::strXML(size_t prefix)
 {
     std::stringstream ss;
     std::vector<ElementPtr> v;
     pre(ss, prefix);
     ss << "<list>" << endl;;
-    v = list_value();
+    v = listValue();
     for (std::vector<ElementPtr>::iterator it = v.begin(); it != v.end(); ++it) {
         pre(ss, prefix + 4);
         ss << "<listitem>" << endl;
-        ss << (*it)->str_xml(prefix + 8) << endl;
+        ss << (*it)->strXML(prefix + 8) << endl;
         pre(ss, prefix + 4);
         ss << "</listitem>" << endl;
     }
@@ -524,18 +524,18 @@ ListElement::str_xml(size_t prefix)
 }
 
 std::string
-MapElement::str_xml(size_t prefix)
+MapElement::strXML(size_t prefix)
 {
     std::stringstream ss;
     std::map<std::string, ElementPtr> m;
-    m = map_value();
+    m = mapValue();
     pre(ss, prefix);
     ss << "<map>" << endl;
     for (std::map<std::string, ElementPtr>::iterator it = m.begin(); it != m.end(); ++it) {
         pre(ss, prefix + 4);
         ss << "<mapitem name=\"" << (*it).first << "\">" << endl;
         pre(ss, prefix);
-        ss << (*it).second->str_xml(prefix+8) << endl;
+        ss << (*it).second->strXML(prefix+8) << endl;
         pre(ss, prefix + 4);
         ss << "</mapitem>" << endl;
     }
@@ -551,7 +551,7 @@ MapElement::str_xml(size_t prefix)
 ElementPtr
 MapElement::find(const std::string& id)
 {
-    if (get_type() != map) {
+    if (getType() != map) {
         throw TypeError();
     }
     size_t sep = id.find('/');
@@ -752,15 +752,15 @@ decode_element(std::stringstream& in, int& in_length)
 }
 
 ElementPtr
-Element::from_wire(const std::string& s)
+Element::fromWire(const std::string& s)
 {
     std::stringstream ss;
     ss << s;
-    return from_wire(ss, s.length());
+    return fromWire(ss, s.length());
 }
 
 ElementPtr
-Element::from_wire(std::stringstream& in, int length)
+Element::fromWire(std::stringstream& in, int length)
 {
     //
     // Check protocol version
@@ -812,18 +812,18 @@ encode_length(unsigned int length, unsigned char type)
 }
 
 std::string
-StringElement::to_wire(int omit_length)
+StringElement::toWire(int omit_length)
 {
     std::stringstream ss;
 
-    int length = string_value().length();
-    ss << encode_length(length, ITEM_UTF8) << string_value();
+    int length = stringValue().length();
+    ss << encode_length(length, ITEM_UTF8) << stringValue();
 
     return ss.str();
 }
 
 std::string
-IntElement::to_wire(int omit_length)
+IntElement::toWire(int omit_length)
 {
     std::stringstream ss;
     std::stringstream text;
@@ -836,7 +836,7 @@ IntElement::to_wire(int omit_length)
 }
 
 std::string
-BoolElement::to_wire(int omit_length)
+BoolElement::toWire(int omit_length)
 {
     std::stringstream ss;
     std::stringstream text;
@@ -844,7 +844,7 @@ BoolElement::to_wire(int omit_length)
     text << str();
     int length = 1;
     ss << encode_length(length, ITEM_BOOL);
-    if (bool_value()) {
+    if (boolValue()) {
         ss << 0x01;
     } else {
         ss << 0x00;
@@ -854,7 +854,7 @@ BoolElement::to_wire(int omit_length)
 }
 
 std::string
-DoubleElement::to_wire(int omit_length)
+DoubleElement::toWire(int omit_length)
 {
     std::stringstream ss;
     std::stringstream text;
@@ -867,14 +867,14 @@ DoubleElement::to_wire(int omit_length)
 }
 
 std::string
-ListElement::to_wire(int omit_length)
+ListElement::toWire(int omit_length)
 {
     std::stringstream ss;
     std::vector<ElementPtr> v;
-    v = list_value();
+    v = listValue();
     for (std::vector<ElementPtr>::iterator it = v.begin() ;
          it != v.end() ; ++it) {
-        ss << (*it)->to_wire(0);
+        ss << (*it)->toWire(0);
     }
 
     if (omit_length) {
@@ -900,7 +900,7 @@ encode_tag(const std::string &s)
 }
 
 std::string
-MapElement::to_wire(int omit_length)
+MapElement::toWire(int omit_length)
 {
     std::stringstream ss;
     std::map<std::string, ElementPtr> m;
@@ -913,11 +913,11 @@ MapElement::to_wire(int omit_length)
         ss << PROTOCOL_VERSION[2] << PROTOCOL_VERSION[3];
     }
 
-    m = map_value();
+    m = mapValue();
     for (std::map<std::string, ElementPtr>::iterator it = m.begin() ;
          it != m.end() ; ++it) {
         ss << encode_tag((*it).first);
-        ss << (*it).second->to_wire(0);
+        ss << (*it).second->toWire(0);
     }
 
     //
@@ -949,7 +949,7 @@ MapElement::find(const std::string& id, ElementPtr& t) {
 }
 
 bool
-isc::data::is_null(ElementPtr p)
+isc::data::isNull(ElementPtr p)
 {
     return !p;
 }

+ 63 - 63
src/lib/cc/cpp/data.h

@@ -48,7 +48,7 @@ namespace isc { namespace data {
     private:
         // technically the type could be omitted; is it useful?
         // should we remove it or replace it with a pure virtual
-        // function get_type?
+        // function getType?
         int type;
 
     protected:
@@ -60,12 +60,12 @@ namespace isc { namespace data {
         virtual ~Element() {};
 
         // returns the type of this element
-        int get_type() { return type; };
+        int getType() { return type; };
         
         // pure virtuals, every derived class must implement these
 
         // returns a string representing the Element and all its
-        // child elements; note that this is different from string_value(),
+        // child elements; note that this is different from stringValue(),
         // which only returns the single value of a StringElement
         // A MapElement will be represented as { "name1": <value1>, "name2", <value2>, .. }
         // A ListElement will be represented as [ <item1>, <item2>, .. ]
@@ -74,23 +74,23 @@ namespace isc { namespace data {
 
         // returns an xml representation for the Element and all its
         // child elements
-        virtual std::string str_xml(size_t prefix = 0) = 0;
+        virtual std::string strXML(size_t prefix = 0) = 0;
 
         // returns the wireformat for the Element and all its child
         // elements
-        virtual std::string to_wire(int omit_length = 1) = 0;
+        virtual std::string toWire(int omit_length = 1) = 0;
 
         // Specific getters for each type. These functions only
         // work on their corresponding Element type. For all other
         // types, a TypeError is thrown.
         // If you want an exception-safe getter method, use
-        // get_value() below
-        virtual int int_value() { throw TypeError(); };
-        virtual double double_value() { throw TypeError(); };
-        virtual bool bool_value() { throw TypeError(); };
-        virtual std::string string_value() { throw TypeError(); };
-        virtual const std::vector<boost::shared_ptr<Element> >& list_value() { throw TypeError(); }; // replace with real exception or empty vector?
-        virtual const std::map<std::string, boost::shared_ptr<Element> >& map_value() { throw TypeError(); }; // replace with real exception or empty map?
+        // getValue() below
+        virtual int intValue() { throw TypeError(); };
+        virtual double doubleValue() { throw TypeError(); };
+        virtual bool boolValue() { throw TypeError(); };
+        virtual std::string stringValue() { throw TypeError(); };
+        virtual const std::vector<boost::shared_ptr<Element> >& listValue() { throw TypeError(); }; // replace with real exception or empty vector?
+        virtual const std::map<std::string, boost::shared_ptr<Element> >& mapValue() { throw TypeError(); }; // replace with real exception or empty map?
 
         // Other functions for specific subtypes
 
@@ -116,24 +116,24 @@ namespace isc { namespace data {
         // should override the function for their type, copying their
         // data to the given reference and returning true
         //
-        virtual bool get_value(int& t) { return false; };
-        virtual bool get_value(double& t) { return false; };
-        virtual bool get_value(bool& t) { return false; };
-        virtual bool get_value(std::string& t) { return false; };
-        virtual bool get_value(std::vector<ElementPtr>& t) { return false; };
-        virtual bool get_value(std::map<std::string, ElementPtr>& t) { return false; };
+        virtual bool getValue(int& t) { return false; };
+        virtual bool getValue(double& t) { return false; };
+        virtual bool getValue(bool& t) { return false; };
+        virtual bool getValue(std::string& t) { return false; };
+        virtual bool getValue(std::vector<ElementPtr>& t) { return false; };
+        virtual bool getValue(std::map<std::string, ElementPtr>& t) { return false; };
 
         //
         // Exception-safe setters. Return false if the Element is not
         // the right type. Set the value and return true if the Elements
         // is of the correct type
         //
-        virtual bool set_value(const int v) { return false; };
-        virtual bool set_value(const double v) { return false; };
-        virtual bool set_value(const bool t) { return false; };
-        virtual bool set_value(const std::string& v) { return false; };
-        virtual bool set_value(const std::vector<ElementPtr>& v) { return false; };
-        virtual bool set_value(const std::map<std::string, ElementPtr>& v) { return false; };
+        virtual bool setValue(const int v) { return false; };
+        virtual bool setValue(const double v) { return false; };
+        virtual bool setValue(const bool t) { return false; };
+        virtual bool setValue(const std::string& v) { return false; };
+        virtual bool setValue(const std::vector<ElementPtr>& v) { return false; };
+        virtual bool setValue(const std::map<std::string, ElementPtr>& v) { return false; };
 
         // should we move all factory functions to a different class
         // so as not to burden the Element base with too many functions?
@@ -157,18 +157,18 @@ namespace isc { namespace data {
         // return a NULL ElementPtr if there is a parse error or
         // the memory could not be allocated
         // example:
-        // ElementPtr my_element = Element::create_from_string("{\"foo\": [ 1, 2, false ] }");
-        //static ElementPtr create_from_string(std::stringstream& in);
-        static ElementPtr create_from_string(const std::string& in);
-        static ElementPtr create_from_string(std::istream& in) throw(ParseError);
+        // ElementPtr my_element = Element::createFromString("{\"foo\": [ 1, 2, false ] }");
+        //static ElementPtr createFromString(std::stringstream& in);
+        static ElementPtr createFromString(const std::string& in);
+        static ElementPtr createFromString(std::istream& in) throw(ParseError);
         // make this one private?
-        static ElementPtr create_from_string(std::istream& in, int& line, int &pos) throw(ParseError);
+        static ElementPtr createFromString(std::istream& in, int& line, int &pos) throw(ParseError);
         
         //static ElementPtr create_from_xml(std::stringstream& in);
 
         // factory functions for wireformat
-        static ElementPtr from_wire(std::stringstream& in, int length);
-        static ElementPtr from_wire(const std::string& s);
+        static ElementPtr fromWire(std::stringstream& in, int length);
+        static ElementPtr fromWire(const std::string& s);
     };
 
     class IntElement : public Element {
@@ -176,12 +176,12 @@ namespace isc { namespace data {
 
     public:
         IntElement(int v) : Element(integer), i(v) { };
-        int int_value() { return i; }
-        bool get_value(int& t) { t = i; return true; };
-        bool set_value(const int v) { i = v; return true; };
+        int intValue() { return i; }
+        bool getValue(int& t) { t = i; return true; };
+        bool setValue(const int v) { i = v; return true; };
         std::string str();
-        std::string str_xml(size_t prefix = 0);
-        std::string to_wire(int omit_length = 1);
+        std::string strXML(size_t prefix = 0);
+        std::string toWire(int omit_length = 1);
     };
 
     class DoubleElement : public Element {
@@ -189,12 +189,12 @@ namespace isc { namespace data {
 
     public:
         DoubleElement(double v) : Element(real), d(v) {};
-        double double_value() { return d; }
-        bool get_value(double& t) { t = d; return true; };
-        bool set_value(const double v) { d = v; return true; };
+        double doubleValue() { return d; }
+        bool getValue(double& t) { t = d; return true; };
+        bool setValue(const double v) { d = v; return true; };
         std::string str();
-        std::string str_xml(size_t prefix = 0);
-        std::string to_wire(int omit_length = 1);
+        std::string strXML(size_t prefix = 0);
+        std::string toWire(int omit_length = 1);
     };
 
     class BoolElement : public Element {
@@ -202,12 +202,12 @@ namespace isc { namespace data {
 
     public:
         BoolElement(const bool v) : Element(boolean), b(v) {};
-        bool bool_value() { return b; }
-        bool get_value(bool& t) { t = b; return true; };
-        bool set_value(const bool v) { b = v; return true; };
+        bool boolValue() { return b; }
+        bool getValue(bool& t) { t = b; return true; };
+        bool setValue(const bool v) { b = v; return true; };
         std::string str();
-        std::string str_xml(size_t prefix = 0);
-        std::string to_wire(int omit_length = 1);
+        std::string strXML(size_t prefix = 0);
+        std::string toWire(int omit_length = 1);
     };
     
     class StringElement : public Element {
@@ -215,12 +215,12 @@ namespace isc { namespace data {
 
     public:
         StringElement(std::string v) : Element(string), s(v) {};
-        std::string string_value() { return s; };
-        bool get_value(std::string& t) { t = s; return true; };
-        bool set_value(const std::string& v) { s = v; return true; };
+        std::string stringValue() { return s; };
+        bool getValue(std::string& t) { t = s; return true; };
+        bool setValue(const std::string& v) { s = v; return true; };
         std::string str();
-        std::string str_xml(size_t prefix = 0);
-        std::string to_wire(int omit_length = 1);
+        std::string strXML(size_t prefix = 0);
+        std::string toWire(int omit_length = 1);
     };
 
     class ListElement : public Element {
@@ -228,16 +228,16 @@ namespace isc { namespace data {
 
     public:
         ListElement(std::vector<ElementPtr> v) : Element(list), l(v) {};
-        const std::vector<ElementPtr>& list_value() { return l; }
-        bool get_value(std::vector<ElementPtr>& t) { t = l; return true; };
-        bool set_value(const std::vector<ElementPtr>& v) { l = v; return true; };
+        const std::vector<ElementPtr>& listValue() { return l; }
+        bool getValue(std::vector<ElementPtr>& t) { t = l; return true; };
+        bool setValue(const std::vector<ElementPtr>& v) { l = v; return true; };
         ElementPtr get(int i) { return l.at(i); };
         void set(int i, ElementPtr e) { l[i] = e; };
         void add(ElementPtr e) { l.push_back(e); };
         void remove(int i) { l.erase(l.begin() + i); };
         std::string str();
-        std::string str_xml(size_t prefix = 0);
-        std::string to_wire(int omit_length = 1);
+        std::string strXML(size_t prefix = 0);
+        std::string toWire(int omit_length = 1);
         size_t size() { return l.size(); }
     };
 
@@ -246,21 +246,21 @@ namespace isc { namespace data {
 
     public:
         MapElement(std::map<std::string, ElementPtr> v) : Element(map), m(v) {};
-        const std::map<std::string, ElementPtr>& map_value() { return m; }
-        bool get_value(std::map<std::string, ElementPtr>& t) { t = m; return true; };
-        bool set_value(std::map<std::string, ElementPtr>& v) { m = v; return true; };
+        const std::map<std::string, ElementPtr>& mapValue() { return m; }
+        bool getValue(std::map<std::string, ElementPtr>& t) { t = m; return true; };
+        bool setValue(std::map<std::string, ElementPtr>& v) { m = v; return true; };
         ElementPtr get(const std::string& s) { return m[s]; };
         void set(const std::string& s, ElementPtr p) { m[s] = p; };
         void remove(const std::string& s) { m.erase(s); }
         bool contains(const std::string& s) { return m.find(s) != m.end(); }
         std::string str();
-        std::string str_xml(size_t prefix = 0);
-        std::string to_wire(int omit_length = 1);
+        std::string strXML(size_t prefix = 0);
+        std::string toWire(int omit_length = 1);
         
         //
         // Encode into the CC wire format.
         //
-        void to_wire(std::ostream& ss);
+        void toWire(std::ostream& ss);
 
         // we should name the two finds better...
         // find the element at id; raises TypeError if one of the
@@ -276,7 +276,7 @@ namespace isc { namespace data {
         bool find(const std::string& id, ElementPtr& t);
     };
 
-    bool is_null(ElementPtr p);
+    bool isNull(ElementPtr p);
 } }
 
 // add a << operator for output streams so we can do

+ 21 - 21
src/lib/cc/cpp/data_def.cc

@@ -11,7 +11,7 @@ using namespace isc::data;
 
 // todo: is there a direct way to get a std::string from an enum label?
 static std::string
-get_type_string(Element::types type)
+getType_string(Element::types type)
 {
     switch(type) {
     case Element::integer:
@@ -32,7 +32,7 @@ get_type_string(Element::types type)
 }
 
 static Element::types
-get_type_value(const std::string& type_name) {
+getType_value(const std::string& type_name) {
     if (type_name == "integer") {
         return Element::integer;
     } else if (type_name == "real") {
@@ -54,10 +54,10 @@ static void
 check_leaf_item(const ElementPtr& spec, const std::string& name, Element::types type, bool mandatory)
 {
     if (spec->contains(name)) {
-        if (spec->get(name)->get_type() == type) {
+        if (spec->get(name)->getType() == type) {
             return;
         } else {
-            throw DataDefinitionError(name + " not of type " + get_type_string(type));
+            throw DataDefinitionError(name + " not of type " + getType_string(type));
         }
     } else if (mandatory) {
         // todo: want parent item name, and perhaps some info about location
@@ -75,17 +75,17 @@ check_config_item(const ElementPtr& spec) {
     check_leaf_item(spec, "item_type", Element::string, true);
     check_leaf_item(spec, "item_optional", Element::boolean, true);
     check_leaf_item(spec, "item_default",
-                    get_type_value(spec->get("item_type")->string_value()),
-                    !spec->get("item_optional")->bool_value()
+                    getType_value(spec->get("item_type")->stringValue()),
+                    !spec->get("item_optional")->boolValue()
                    );
 
     // if list, check the list definition
-    if (get_type_value(spec->get("item_type")->string_value()) == Element::list) {
+    if (getType_value(spec->get("item_type")->stringValue()) == Element::list) {
         check_leaf_item(spec, "list_item_spec", Element::map, true);
         check_config_item(spec->get("list_item_spec"));
     }
     // todo: add stuff for type map
-    if (get_type_value(spec->get("item_type")->string_value()) == Element::map) {
+    if (getType_value(spec->get("item_type")->stringValue()) == Element::map) {
         check_leaf_item(spec, "map_item_spec", Element::list, true);
         check_config_item_list(spec);
     }
@@ -93,10 +93,10 @@ check_config_item(const ElementPtr& spec) {
 
 static void
 check_config_item_list(const ElementPtr& spec) {
-    if (spec->get_type() != Element::list) {
+    if (spec->getType() != Element::list) {
         throw DataDefinitionError("config_data is not a list of elements");
     }
-    BOOST_FOREACH(ElementPtr item, spec->list_value()) {
+    BOOST_FOREACH(ElementPtr item, spec->listValue()) {
         check_config_item(item);
     }
 }
@@ -110,10 +110,10 @@ check_command(const ElementPtr& spec) {
 
 static void
 check_command_list(const ElementPtr& spec) {
-    if (spec->get_type() != Element::list) {
+    if (spec->getType() != Element::list) {
         throw DataDefinitionError("commands is not a list of elements");
     }
-    BOOST_FOREACH(ElementPtr item, spec->list_value()) {
+    BOOST_FOREACH(ElementPtr item, spec->listValue()) {
         check_command(item);
     }
 }
@@ -145,7 +145,7 @@ check_definition(const ElementPtr& def)
 
 DataDefinition::DataDefinition(std::istream& in, const bool check)
                                throw(ParseError, DataDefinitionError) {
-    definition = Element::create_from_string(in);
+    definition = Element::createFromString(in);
     // make sure the whole structure is complete and valid
     if (check) {
         check_definition(definition);
@@ -159,11 +159,11 @@ static bool
 check_type(ElementPtr spec, ElementPtr element)
 {
     std::string cur_item_type;
-    cur_item_type = spec->get("item_type")->string_value();
+    cur_item_type = spec->get("item_type")->stringValue();
     if (cur_item_type == "any") {
         return true;
     }
-    switch (element->get_type()) {
+    switch (element->getType()) {
         case Element::integer:
             return cur_item_type == "integer";
             break;
@@ -194,14 +194,14 @@ DataDefinition::validate_item(const ElementPtr spec, const ElementPtr data) {
         std::cout << spec << std::endl;
         return false;
     }
-    if (data->get_type() == Element::list) {
-        BOOST_FOREACH(ElementPtr list_el, data->list_value()) {
+    if (data->getType() == Element::list) {
+        BOOST_FOREACH(ElementPtr list_el, data->listValue()) {
             if (!validate_spec(spec->get("list_item_spec"), list_el)) {
                 return false;
             }
         }
     }
-    if (data->get_type() == Element::map) {
+    if (data->getType() == Element::map) {
         if (!validate_spec_list(spec->get("map_item_spec"), data)) {
             return false;
         }
@@ -212,8 +212,8 @@ DataDefinition::validate_item(const ElementPtr spec, const ElementPtr data) {
 // spec is a map with item_name etc, data is a map
 bool
 DataDefinition::validate_spec(const ElementPtr spec, const ElementPtr data) {
-    std::string item_name = spec->get("item_name")->string_value();
-    bool optional = spec->get("item_optional")->bool_value();
+    std::string item_name = spec->get("item_name")->stringValue();
+    bool optional = spec->get("item_optional")->boolValue();
     ElementPtr data_el;
     
     std::cout << "check for item with name " << item_name << std::endl;
@@ -236,7 +236,7 @@ bool
 DataDefinition::validate_spec_list(const ElementPtr spec, const ElementPtr data) {
     ElementPtr cur_data_el;
     std::string cur_item_name;
-    BOOST_FOREACH(ElementPtr cur_spec_el, spec->list_value()) {
+    BOOST_FOREACH(ElementPtr cur_spec_el, spec->listValue()) {
         if (!validate_spec(cur_spec_el, data)) {
             return false;
         }

+ 55 - 55
src/lib/cc/cpp/data_unittests.cc

@@ -23,22 +23,22 @@
 using namespace isc::data;
 
 TEST(Element, type) {
-    // this tests checks whether the get_type() function returns the
+    // this tests checks whether the getType() function returns the
     // correct type
     IntElement int_el = IntElement(1);
-    EXPECT_EQ(int_el.get_type(), Element::integer);
+    EXPECT_EQ(int_el.getType(), Element::integer);
     DoubleElement double_el = DoubleElement(1.0);
-    EXPECT_EQ(double_el.get_type(), Element::real);
+    EXPECT_EQ(double_el.getType(), Element::real);
     BoolElement bool_el = BoolElement(true);
-    EXPECT_EQ(bool_el.get_type(), Element::boolean);
+    EXPECT_EQ(bool_el.getType(), Element::boolean);
     StringElement str_el = StringElement("foo");
-    EXPECT_EQ(str_el.get_type(), Element::string);
+    EXPECT_EQ(str_el.getType(), Element::string);
     std::vector<ElementPtr> v;
     ListElement list_el = ListElement(v);
-    EXPECT_EQ(list_el.get_type(), Element::list);
+    EXPECT_EQ(list_el.getType(), Element::list);
     std::map<std::string, ElementPtr> m;
     MapElement map_el = MapElement(m);
-    EXPECT_EQ(map_el.get_type(), Element::map);
+    EXPECT_EQ(map_el.getType(), Element::map);
 }
 
 TEST(Element, str) {
@@ -56,7 +56,7 @@ TEST(Element, str) {
     sv.push_back("{\"name\": \"foo\", \"value\": 47806}");
 
     BOOST_FOREACH(std::string s, sv) {
-        el = Element::create_from_string(s);
+        el = Element::createFromString(s);
         EXPECT_EQ(el->str(), s);
     }
 }
@@ -67,63 +67,63 @@ TEST(Element, create_and_value_throws) {
     ElementPtr el;
 
     el = Element::create(1);
-    EXPECT_THROW(el->double_value(), TypeError);
-    EXPECT_THROW(el->bool_value(), TypeError);
-    EXPECT_THROW(el->string_value(), TypeError);
-    EXPECT_THROW(el->list_value(), TypeError);
-    EXPECT_THROW(el->map_value(), TypeError);
+    EXPECT_THROW(el->doubleValue(), TypeError);
+    EXPECT_THROW(el->boolValue(), TypeError);
+    EXPECT_THROW(el->stringValue(), TypeError);
+    EXPECT_THROW(el->listValue(), TypeError);
+    EXPECT_THROW(el->mapValue(), TypeError);
 
     el = Element::create(1.1);
-    EXPECT_THROW(el->int_value(), TypeError);
-    EXPECT_THROW(el->bool_value(), TypeError);
-    EXPECT_THROW(el->string_value(), TypeError);
-    EXPECT_THROW(el->list_value(), TypeError);
-    EXPECT_THROW(el->map_value(), TypeError);
+    EXPECT_THROW(el->intValue(), TypeError);
+    EXPECT_THROW(el->boolValue(), TypeError);
+    EXPECT_THROW(el->stringValue(), TypeError);
+    EXPECT_THROW(el->listValue(), TypeError);
+    EXPECT_THROW(el->mapValue(), TypeError);
 
     el = Element::create(true);
-    EXPECT_THROW(el->int_value(), TypeError);
-    EXPECT_THROW(el->double_value(), TypeError);
-    EXPECT_THROW(el->string_value(), TypeError);
-    EXPECT_THROW(el->list_value(), TypeError);
-    EXPECT_THROW(el->map_value(), TypeError);
+    EXPECT_THROW(el->intValue(), TypeError);
+    EXPECT_THROW(el->doubleValue(), TypeError);
+    EXPECT_THROW(el->stringValue(), TypeError);
+    EXPECT_THROW(el->listValue(), TypeError);
+    EXPECT_THROW(el->mapValue(), TypeError);
 
     el = Element::create("foo");
-    EXPECT_THROW(el->int_value(), TypeError);
-    EXPECT_THROW(el->double_value(), TypeError);
-    EXPECT_THROW(el->bool_value(), TypeError);
-    EXPECT_THROW(el->list_value(), TypeError);
-    EXPECT_THROW(el->map_value(), TypeError);
+    EXPECT_THROW(el->intValue(), TypeError);
+    EXPECT_THROW(el->doubleValue(), TypeError);
+    EXPECT_THROW(el->boolValue(), TypeError);
+    EXPECT_THROW(el->listValue(), TypeError);
+    EXPECT_THROW(el->mapValue(), TypeError);
 
     std::vector<ElementPtr> v;
     el = Element::create(v);
-    EXPECT_THROW(el->int_value(), TypeError);
-    EXPECT_THROW(el->double_value(), TypeError);
-    EXPECT_THROW(el->bool_value(), TypeError);
-    EXPECT_THROW(el->string_value(), TypeError);
-    EXPECT_THROW(el->map_value(), TypeError);
+    EXPECT_THROW(el->intValue(), TypeError);
+    EXPECT_THROW(el->doubleValue(), TypeError);
+    EXPECT_THROW(el->boolValue(), TypeError);
+    EXPECT_THROW(el->stringValue(), TypeError);
+    EXPECT_THROW(el->mapValue(), TypeError);
 
     std::map<std::string, ElementPtr> m;
     el = Element::create(m);
-    EXPECT_THROW(el->int_value(), TypeError);
-    EXPECT_THROW(el->double_value(), TypeError);
-    EXPECT_THROW(el->bool_value(), TypeError);
-    EXPECT_THROW(el->string_value(), TypeError);
-    EXPECT_THROW(el->list_value(), TypeError);
+    EXPECT_THROW(el->intValue(), TypeError);
+    EXPECT_THROW(el->doubleValue(), TypeError);
+    EXPECT_THROW(el->boolValue(), TypeError);
+    EXPECT_THROW(el->stringValue(), TypeError);
+    EXPECT_THROW(el->listValue(), TypeError);
 
 }
 
 TEST(Element, ListElement) {
     // this function checks the specific functions for ListElements
-    ElementPtr el = Element::create_from_string("[ 1, \"bar\", 3 ]");
-    EXPECT_EQ(el->get(0)->int_value(), 1);
-    EXPECT_EQ(el->get(1)->string_value(), "bar");
-    EXPECT_EQ(el->get(2)->int_value(), 3);
+    ElementPtr el = Element::createFromString("[ 1, \"bar\", 3 ]");
+    EXPECT_EQ(el->get(0)->intValue(), 1);
+    EXPECT_EQ(el->get(1)->stringValue(), "bar");
+    EXPECT_EQ(el->get(2)->intValue(), 3);
 
-    el->set(0, Element::create_from_string("\"foo\""));
-    EXPECT_EQ(el->get(0)->string_value(), "foo");
+    el->set(0, Element::createFromString("\"foo\""));
+    EXPECT_EQ(el->get(0)->stringValue(), "foo");
 
     el->add(Element::create(47806));
-    EXPECT_EQ(el->get(3)->int_value(), 47806);
+    EXPECT_EQ(el->get(3)->intValue(), 47806);
 
     el->remove(1);
     el->remove(1);
@@ -133,27 +133,27 @@ TEST(Element, ListElement) {
     EXPECT_ANY_THROW(el->get(3));
 
     el->add(Element::create(32));
-    EXPECT_EQ(el->get(2)->int_value(), 32);
+    EXPECT_EQ(el->get(2)->intValue(), 32);
 }
 
 TEST(Element, MapElement) {
     // this function checks the specific functions for ListElements
-    ElementPtr el = Element::create_from_string("{ \"name\": \"foo\", \"value1\": \"bar\", \"value2\": { \"number\": 42 } }");
+    ElementPtr el = Element::createFromString("{ \"name\": \"foo\", \"value1\": \"bar\", \"value2\": { \"number\": 42 } }");
 
-    EXPECT_EQ(el->get("name")->string_value(), "foo");
-    EXPECT_EQ(el->get("value2")->get_type(), Element::map);
+    EXPECT_EQ(el->get("name")->stringValue(), "foo");
+    EXPECT_EQ(el->get("value2")->getType(), Element::map);
 
-    EXPECT_TRUE(is_null(el->get("value3")));
+    EXPECT_TRUE(isNull(el->get("value3")));
 
     el->set("value3", Element::create(47806));
-    EXPECT_EQ(el->get("value3")->int_value(), 47806);
+    EXPECT_EQ(el->get("value3")->intValue(), 47806);
 
     el->remove("value3");
-    EXPECT_TRUE(is_null(el->get("value3")));
+    EXPECT_TRUE(isNull(el->get("value3")));
 
-    EXPECT_EQ(el->find("value2/number")->int_value(), 42);
+    EXPECT_EQ(el->find("value2/number")->intValue(), 42);
    
-    EXPECT_EQ(el->find("value1")->string_value(), "bar");
-    EXPECT_EQ(el->find("value1/")->string_value(), "bar");
+    EXPECT_EQ(el->find("value1")->stringValue(), "bar");
+    EXPECT_EQ(el->find("value1/")->stringValue(), "bar");
 }
 

+ 13 - 13
src/lib/cc/cpp/session.cc

@@ -54,13 +54,13 @@ Session::establish()
     std::string get_lname_str = "{ \"type\": \"getlname\" }";
     std::stringstream get_lname_stream;
     get_lname_stream.str(get_lname_str);
-    ElementPtr get_lname_msg = Element::create_from_string(get_lname_stream);
+    ElementPtr get_lname_msg = Element::createFromString(get_lname_stream);
     sendmsg(get_lname_msg);
 
     ElementPtr routing, msg;
     recvmsg(routing, msg, false);
 
-    lname = msg->get("lname")->string_value();
+    lname = msg->get("lname")->stringValue();
     cout << "My local name is:  " << lname << endl;
 }
 
@@ -70,7 +70,7 @@ Session::establish()
 void
 Session::sendmsg(ElementPtr& msg)
 {
-    std::string header_wire = msg->to_wire();
+    std::string header_wire = msg->toWire();
     unsigned int length = 2 + header_wire.length();
     unsigned int length_net = htonl(length);
     unsigned short header_length = header_wire.length();
@@ -94,8 +94,8 @@ Session::sendmsg(ElementPtr& msg)
 void
 Session::sendmsg(ElementPtr& env, ElementPtr& msg)
 {
-    std::string header_wire = env->to_wire();
-    std::string body_wire = msg->to_wire();
+    std::string header_wire = env->toWire();
+    std::string body_wire = msg->toWire();
     unsigned int length = 2 + header_wire.length() + body_wire.length();
     unsigned int length_net = htonl(length);
     unsigned short header_length = header_wire.length();
@@ -152,7 +152,7 @@ Session::recvmsg(ElementPtr& msg, bool nonblock)
     std::stringstream wire_stream;
     wire_stream <<wire;
 
-    msg = Element::from_wire(wire_stream, length);
+    msg = Element::fromWire(wire_stream, length);
 
     return (true);
     // XXXMLG handle non-block here, and return false for short reads
@@ -191,11 +191,11 @@ Session::recvmsg(ElementPtr& env, ElementPtr& msg, bool nonblock)
 
     std::stringstream header_wire_stream;
     header_wire_stream << header_wire;
-    env = Element::from_wire(header_wire_stream, header_length);
+    env = Element::fromWire(header_wire_stream, header_length);
     
     std::stringstream body_wire_stream;
     body_wire_stream << body_wire;
-    msg = Element::from_wire(body_wire_stream, length - header_length);
+    msg = Element::fromWire(body_wire_stream, length - header_length);
 
     return (true);
     // XXXMLG handle non-block here, and return false for short reads
@@ -237,7 +237,7 @@ Session::group_sendmsg(ElementPtr msg, std::string group,
     env->set("group", Element::create(group));
     env->set("instance", Element::create(instance));
     env->set("seq", Element::create(sequence));
-    //env->set("msg", Element::create(msg->to_wire()));
+    //env->set("msg", Element::create(msg->toWire()));
 
     sendmsg(env, msg);
 
@@ -262,11 +262,11 @@ Session::reply(ElementPtr& envelope, ElementPtr& newmsg)
 
     env->set("type", Element::create("send"));
     env->set("from", Element::create(lname));
-    env->set("to", Element::create(envelope->get("from")->string_value()));
-    env->set("group", Element::create(envelope->get("group")->string_value()));
-    env->set("instance", Element::create(envelope->get("instance")->string_value()));
+    env->set("to", Element::create(envelope->get("from")->stringValue()));
+    env->set("group", Element::create(envelope->get("group")->stringValue()));
+    env->set("instance", Element::create(envelope->get("instance")->stringValue()));
     env->set("seq", Element::create(sequence));
-    env->set("reply", Element::create(envelope->get("seq")->int_value()));
+    env->set("reply", Element::create(envelope->get("seq")->intValue()));
 
     sendmsg(env, newmsg);
 

+ 1 - 1
src/lib/cc/cpp/test.cc

@@ -39,7 +39,7 @@ main(int argc, char **argv) {
         return 1;
     }
     try {
-        data = Element::create_from_string(file);
+        data = Element::createFromString(file);
         cout << "Data: " << endl;
         cout << data << endl;
     } catch (ParseError pe) {