[svn] commit: r183 - in /experiments/jelte-configuration: Makefile.in data.cc data.h test.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Oct 29 22:06:04 UTC 2009


Author: mgraff
Date: Thu Oct 29 22:06:04 2009
New Revision: 183

Log:
split out test into test.cc, and make it link

Added:
    experiments/jelte-configuration/test.cc
Modified:
    experiments/jelte-configuration/Makefile.in
    experiments/jelte-configuration/data.cc
    experiments/jelte-configuration/data.h

Modified: experiments/jelte-configuration/Makefile.in
==============================================================================
--- experiments/jelte-configuration/Makefile.in (original)
+++ experiments/jelte-configuration/Makefile.in Thu Oct 29 22:06:04 2009
@@ -19,8 +19,8 @@
 
 all:	test
 
-test:	data.cc data.h
-	$(CXX) $(CFLAGS) -o test data.cc
+test:	test.o data.o data.h
+	$(CXX) $(CFLAGS) -o test test.o data.o
 
 clean:
 	rm -f *.o test

Modified: experiments/jelte-configuration/data.cc
==============================================================================
--- experiments/jelte-configuration/data.cc (original)
+++ experiments/jelte-configuration/data.cc Thu Oct 29 22:06:04 2009
@@ -5,7 +5,6 @@
 #include <iostream>
 #include <sstream>
 
-#include <boost/foreach.hpp>
 #include <boost/algorithm/string.hpp>
 
 using namespace std;
@@ -23,6 +22,10 @@
 const unsigned char ITEM_LENGTH_16   = 0x10;
 const unsigned char ITEM_LENGTH_8    = 0x20;
 const unsigned char ITEM_LENGTH_MASK = 0x30;
+
+std::ostream& operator <<(std::ostream &out, const ISC::Data::ElementPtr& e) {
+    return out << e->str();
+}
 
 //
 // factory functions
@@ -817,108 +820,3 @@
     }
     return false;
 }
-
-static void
-hexdump(std::string s)
-{
-    
-    const unsigned char *c = (const unsigned char *)s.c_str();
-    int len = s.length();
-
-    int count = 0;
-
-    printf("%4d: ", 0);
-    while (len) {
-        printf("%02x %c ", (*c & 0xff),
-               (isprint((*c & 0xff)) ? (*c & 0xff) : '.'));
-        count++;
-        c++;
-        len--;
-        if (count % 16 == 0)
-            printf("\n%4d: ", count);
-        else if (count % 8 == 0)
-            printf(" | ");
-    }
-    printf("\n");
-}
-
-int main(int argc, char **argv)
-{
-    
-    ElementPtr ie = Element::create(12);
-    cout << "ie value: " << ie->int_value() << endl;
-    ElementPtr de = Element::create(12.0);
-    cout << "de value: " << de->double_value() << endl;
-    ElementPtr se = Element::create(std::string("hello, world").c_str());
-    cout << "se type " << se->get_type() << endl;
-    cout << "se value: " << se->string_value() << endl;
-    std::vector<ElementPtr> v;
-    v.push_back(Element::create(12));
-    v.push_back(ie);
-    ElementPtr ve = Element::create(v);
-    cout << "Vector element:" << endl;
-    cout << ve->str() << endl;
-    cout << "Vector element2:" << endl;
-    BOOST_FOREACH(ElementPtr e, ve->list_value()) {
-        cout << "\t" << e->str() << endl;
-    }
-    //cout << "Vector element direct: " << ve->string_value() << endl;
-
-    //std::string s = "[ 1, 2, 3, 4]";
-    std::string s = "{ \"test\": [ 47806, True, 42, 12.23, 1, \"1asdf\"], \"foo\": \"bar\", \"aaa\": { \"bbb\": { \"ccc\": 1234, \"ddd\": \"blup\" } } }";
-    //std::string s = "{ \"test\": 1 }";
-    //std::string s = "[ 1, 2 ,3\" ]";
-    std::stringstream ss;
-    ss.str(s);
-    ElementPtr e = Element::create_from_string(ss);
-    if (e) {
-        cout << "element read: " << e->str() << endl;
-        //cout << "xml" << endl << e->str_xml() << endl;
-    } else {
-        cout << "could not read element" << endl;
-        exit(0);
-    }
-    cout << "find aaa/bbb/ccc: " << e->find("aaa/bbb/ccc") << endl;
-
-    ElementPtr founde;
-    if (e->find("aaa/bbb", founde)) {
-        cout << "found aaa/bbb: " << founde << endl;
-    } else {
-        cout << "aaa/bbb not found" << endl;
-    }
-    if (e->find("aaa/ccc", founde)) {
-        cout << "found aaa/ccc: " << founde << endl;
-    } else {
-        cout << "aaa/ccc not found" << endl;
-    }
-    //cout << "part: " << e->get("test")->str() << endl;
-/*
-    int i;
-    ie->get_value(i);
-    cout << "value of ie: " << i << endl;
-    std::vector<ElementPtr> v2;
-    ve->set(0, Element::create(123));
-    ve->get_value(v2);
-    cout << "V2:" << endl;
-    BOOST_FOREACH(ElementPtr e, v2) {
-        cout << "\t" << e->str() << endl;
-    }
-
-    cout << "test: " << e << endl;
-*/
-    ElementPtr be = Element::create(true);
-    cout << "boolelement: " << be << endl;
-
-    std::string s_skan = "{ \"test\": \"testval\", \"xxx\": \"that\", \"int\": 123456, \"list\": [ 1, 2, 3 ], \"map\": { \"one\": \"ONE\" }, \"double\": 5.4, \"boolean\": True }";
-    std::stringstream in_ss_skan;
-    in_ss_skan.str(s_skan);
-    ElementPtr e_skan = Element::create_from_string(in_ss_skan);
-    std::stringstream ss_skan;
-    ss_skan << e_skan->to_wire(1);
-    hexdump(std::string(ss_skan.str()));
-
-    ElementPtr decoded = Element::from_wire(ss_skan, ss_skan.str().length());
-    cout << decoded << endl;
-
-    return 0;
-}

Modified: experiments/jelte-configuration/data.h
==============================================================================
--- experiments/jelte-configuration/data.h (original)
+++ experiments/jelte-configuration/data.h Thu Oct 29 22:06:04 2009
@@ -241,7 +241,6 @@
 // add a << operator for output streams so we can do
 // ElementPtr foo = ...
 // cout << "Element: " << foo;
-std::ostream& operator <<(std::ostream &out, const ISC::Data::ElementPtr& e) {
-    return out << e->str();
-}
+std::ostream& operator <<(std::ostream &out, const ISC::Data::ElementPtr& e);
+
 #endif // _DATA_H




More information about the bind10-changes mailing list