EvolvingObjects
Object.cpp
00001 /*
00002 (c) Thales group, 2012
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Lesser General Public
00006     License as published by the Free Software Foundation;
00007     version 2 of the License.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Lesser General Public License for more details.
00013 
00014     You should have received a copy of the GNU Lesser General Public
00015     License along with this library; if not, write to the Free Software
00016     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 Contact: http://eodev.sourceforge.net
00018 
00019 Authors:
00020     Benjamin Bouvier <benjamin.bouvier@gmail.com>
00021 */
00022 # include "Object.h"
00023 
00024 using namespace eoserial;
00025 
00026 namespace eoserial
00027 {
00028     std::ostream& Object::print( std::ostream& out ) const
00029     {
00030         out << '{';
00031         bool first = true;
00032         for(JsonValues::const_iterator it = begin(), end = this->end();
00033                 it != end;
00034                 ++it)
00035         {
00036             if ( first )
00037             {
00038                 first = false;
00039             } else {
00040                 out << ", ";
00041             }
00042 
00043             out << '"' << it->first << "\":";   // key
00044             it->second->print( out );           // value
00045         }
00046         out << "}\n";
00047         return out;
00048     }
00049 
00050     Object::~Object()
00051     {
00052         for(JsonValues::iterator it = begin(), end = this->end();
00053                 it != end;
00054                 ++it)
00055         {
00056             delete it->second;
00057         }
00058     }
00059 
00060 } // namespace eoserial
 All Classes Namespaces Files Functions Variables Typedefs Friends