Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

persist/test/bar.cpp

Go to the documentation of this file.
00001 // See ../../license.txt for license information.
00002 //
00003 // bar.cpp
00004 //
00005 // 4-Jul-2003  phamilton  Created
00006 //
00007 
00008 #include "bar.hpp"
00009 #include <iostream>
00010 #include "boost/lexical_cast.hpp"
00011 
00012 using namespace persist_test;
00013 
00014 ph::common::object_base *bar::get_composite_object(const std::string &name)
00015 {
00016         return 0;
00017 }
00018 
00019 bool bar::has(const std::string &name) const
00020 {
00021         return name == "name" || name == "type" || name == "x" || name == "y" || name == "z";
00022 }
00023 
00024 void bar::set(const std::string &name, const std::string &value)
00025 {
00026         if (name == "name")
00027                 _name = value;
00028         else if (name == "type")
00029                 _type = value;
00030         else if (name == "x")
00031                 x = boost::lexical_cast<int>(value);
00032         else if (name == "y")
00033                 y = boost::lexical_cast<double>(value);
00034         else if (name == "z")
00035                 z = boost::lexical_cast<int>(value);
00036 }
00037 
00038 std::string bar::get(const std::string &name) const
00039 {
00040         if (name == "name")
00041                 return _name;
00042         else if (name == "type")
00043                 return _type;
00044         else if (name == "x")
00045                 return boost::lexical_cast<std::string>(x);
00046         else if (name == "y")
00047                 return boost::lexical_cast<std::string>(y);
00048         else if (name == "z")
00049                 return boost::lexical_cast<std::string>(z);
00050         else
00051                 return "unknown: " + name;
00052 }
00053 
00054 bool bar::write(ph::common::object_writer *writer) const
00055 {
00056         ph::common::object_writer_context obj(writer, _type);
00057         obj.attr("name", _name);
00058         {
00059                 ph::common::object_writer_context _x(writer, "x");
00060                 _x.data(boost::lexical_cast<std::string>(x));
00061         }       
00062         {
00063                 ph::common::object_writer_context _x(writer, "y");
00064                 _x.data(boost::lexical_cast<std::string>(y));
00065         }       
00066         {
00067                 ph::common::object_writer_context _x(writer, "z");
00068                 _x.data(boost::lexical_cast<std::string>(z));
00069         }       
00070         return true;
00071 }

Generated on Wed Apr 5 22:03:22 2006 for cppxmlobj by  doxygen 1.4.3