Follow this link to skip to the main content

claraty::FDM_Parse_Tree Class Reference

#include <fdm_parse_tree.h>

Inheritance diagram for claraty::FDM_Parse_Tree:

Inheritance graph
[legend]
Collaboration diagram for claraty::FDM_Parse_Tree:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FDM_Parse_Tree (FDM::Direction dir)
 FDM_Parse_Tree (Parse_Tree parse_tree, FDM::Direction dir)
virtual ~FDM_Parse_Tree ()
void break_on_error (bool perform_break_on_error=true)
void clear ()
Parse_Tree get_parse_tree ()
void set_parse_tree (const Parse_Tree &parse_tree)
bool is_read ()
bool is_write ()
virtual bool eof ()
virtual bool flush ()
void debug (int debugging_level=1)
template<class T>
bool write (const T &x)
template<class T>
bool read (T &x)

Static Public Member Functions

template<class T>
static Parse_Tree object_to_parse_tree (const T &obj)
template<class T>
static bool parse_tree_to_object (T &obj, const Parse_Tree &p_in)
template<class T>
static std::string object_to_string (const T &obj)
template<class T>
static bool string_to_object (T &obj, const std::string &str_in)
template<class T>
static std::ostream & write_object (const T &obj, std::ostream &os)
template<class T>
static bool read_object (T &obj, std::istream &is)

Protected Member Functions

_Stack_Elttop_of_stack ()
void show_stack ()
template<class T1>
bool type_equal (const T1 &x, const T1 &y)
template<class T1, class T2>
bool type_equal (const T1 &x, const T2 &y)
template<class T1, class T2>
bool type_equal ()
template<class T>
bool io_primitive (T &x)
virtual bool _io_object (bool &x)
virtual bool _io_object (unsigned char &x)
virtual bool _io_object (char &x)
virtual bool _io_object (unsigned short &x)
virtual bool _io_object (short &x)
virtual bool _io_object (unsigned int &x)
virtual bool _io_object (int &x)
virtual bool _io_object (unsigned long &x)
virtual bool _io_object (long &x)
virtual bool _io_object (unsigned long long &x)
virtual bool _io_object (long long &x)
virtual bool _io_object (float &x)
virtual bool _io_object (double &x)
virtual bool _io_object (std::string &x)
virtual bool _peek_object (unsigned int &x)
virtual bool _peek_object (std::string &x)
virtual void _begin_map ()
virtual void _begin_array ()
virtual bool _array_resizable_length (int &size)
virtual bool _array_element ()
virtual void _end ()
virtual bool _map_field (const char *name)
virtual bool _start_topform (const char *type_name)
virtual bool _end_topform ()
bool _io_object (std::vector< bool >::reference bit_ref)
template<class T>
bool _io_object (T &x)
FDM_Untyped_Node _map_field_node (const char *name)
FDM_Untyped_Node _array_element_node ()
void _pop_node ()
void _unwind_to_node (FDM_Node &node)
void _ref_node (FDM_Node &node)
void _unref_node (FDM_Node &node)
void _push_node (FDM_Node &node)
int _find_node (FDM_Node &node)

Protected Attributes

std::vector< _Stack_Elt_stack
bool _break_on_error
int _id
bool _write
int _debug

Classes

class  _Stack_Elt

Detailed Description

Definition at line 47 of file fdm_parse_tree.h.


Constructor & Destructor Documentation

claraty::FDM_Parse_Tree::FDM_Parse_Tree ( FDM::Direction  dir  ) 

Definition at line 200 of file fdm_parse_tree.cc.

References set_parse_tree().

00200                                                : 
00201   FDM_Stream(dir), _stack(), _break_on_error(false)
00202 {
00203   set_parse_tree(Parse_Tree());
00204 //   _break_on_error=false;
00205 //   _debug= 0;
00206 }

Here is the call graph for this function:

claraty::FDM_Parse_Tree::FDM_Parse_Tree ( Parse_Tree  parse_tree,
FDM::Direction  dir 
)

Definition at line 191 of file fdm_parse_tree.cc.

References set_parse_tree().

00192                                                  : 
00193   FDM_Stream(dir), _stack(), _break_on_error(false)
00194 {
00195   set_parse_tree(parse_tree);
00196 //   _break_on_error=false;
00197 //   _debug= 0;
00198 }

Here is the call graph for this function:

virtual claraty::FDM_Parse_Tree::~FDM_Parse_Tree (  )  [inline, virtual]

Definition at line 51 of file fdm_parse_tree.h.

00051 {}


Member Function Documentation

void claraty::FDM_Parse_Tree::break_on_error ( bool  perform_break_on_error = true  ) 

Break on Error

Parameters:
[in] perform_break_on_error 
Returns:
void

Definition at line 38 of file fdm_parse_tree.cc.

References _break_on_error.

00039 {
00040   _break_on_error= perform_break_on_error;
00041 }

void claraty::FDM_Parse_Tree::clear (  )  [inline]

Definition at line 55 of file fdm_parse_tree.h.

References _stack.

Referenced by claraty::File_FDM_Parse_Tree::flush(), and set_parse_tree().

00055                {
00056     _stack.clear();
00057     _stack.resize(1);
00058   }

Parse_Tree claraty::FDM_Parse_Tree::get_parse_tree (  )  [inline]

Definition at line 60 of file fdm_parse_tree.h.

References _stack.

Referenced by claraty::File_FDM_Parse_Tree::flush(), object_to_parse_tree(), object_to_string(), and write_object().

00060                               { 
00061     assert(_stack.size() > 0);
00062     return _stack[0].pt; 
00063   }

void claraty::FDM_Parse_Tree::set_parse_tree ( const Parse_Tree parse_tree  )  [inline]

Definition at line 65 of file fdm_parse_tree.h.

References _stack, and clear().

Referenced by claraty::File_FDM_Parse_Tree::_process_next_block(), and FDM_Parse_Tree().

00065                                                     {
00066     clear();
00067     _stack[0].pt= parse_tree;
00068   }

Here is the call graph for this function:

template<class T>
static Parse_Tree claraty::FDM_Parse_Tree::object_to_parse_tree ( const T &  obj  )  [inline, static]

Definition at line 71 of file fdm_parse_tree.h.

References get_parse_tree(), claraty::FDM_Stream::write(), and claraty::FDM::Write.

00071                                                        {
00072     FDM_Parse_Tree stream(FDM::Write);
00073     if(!stream.write(obj)) return Parse_Tree();
00074     return(stream.get_parse_tree());
00075   }

Here is the call graph for this function:

template<class T>
static bool claraty::FDM_Parse_Tree::parse_tree_to_object ( T &  obj,
const Parse_Tree p_in 
) [inline, static]

Definition at line 78 of file fdm_parse_tree.h.

References claraty::FDM_Stream::read(), and claraty::FDM::Read.

Referenced by read_object(), and string_to_object().

00078                                                                    {
00079     FDM_Parse_Tree stream(p_in, FDM::Read);
00080     return(stream.read(obj));
00081   }

Here is the call graph for this function:

template<class T>
static std::string claraty::FDM_Parse_Tree::object_to_string ( const T &  obj  )  [inline, static]

Definition at line 84 of file fdm_parse_tree.h.

References get_parse_tree(), claraty::Parse_Tree::pretty_print(), claraty::FDM_Stream::write(), and claraty::FDM::Write.

00084                                                   {
00085     FDM_Parse_Tree stream(FDM::Write);
00086     if(!stream.write(obj)) return "ERROR";
00087     Parse_Tree p_in = stream.get_parse_tree();
00088     return(p_in.pretty_print());
00089   }

Here is the call graph for this function:

template<class T>
static bool claraty::FDM_Parse_Tree::string_to_object ( T &  obj,
const std::string &  str_in 
) [inline, static]

Definition at line 92 of file fdm_parse_tree.h.

References parse_tree_to_object(), and claraty::Parse_Tree::read_from_string().

00092                                                                 {
00093     Parse_Tree p_in;
00094     if(!p_in.read_from_string(str_in)) {
00095       // Parse failed, return false
00096       return(false);
00097     }
00098     return(parse_tree_to_object(obj, p_in));
00099   }

Here is the call graph for this function:

template<class T>
static std::ostream& claraty::FDM_Parse_Tree::write_object ( const T &  obj,
std::ostream &  os 
) [inline, static]

Definition at line 102 of file fdm_parse_tree.h.

References get_parse_tree(), claraty::FDM_Stream::write(), claraty::FDM::Write, and claraty::Parse_Tree::write_to_stream().

Referenced by claraty::operator<<().

00102                                                                 {
00103     FDM_Parse_Tree stream(FDM::Write);
00104     if(!stream.write(obj)) {
00105       os.clear(std::ios::badbit);
00106     }
00107     Parse_Tree p = stream.get_parse_tree();
00108     return(p.write_to_stream(os));
00109   }

Here is the call graph for this function:

template<class T>
static bool claraty::FDM_Parse_Tree::read_object ( T &  obj,
std::istream &  is 
) [inline, static]

Definition at line 112 of file fdm_parse_tree.h.

References parse_tree_to_object(), and claraty::Parse_Tree::read_from_stream().

Referenced by claraty::operator>>().

00112                                                   {
00113     Parse_Tree p;
00114     bool ok=p.read_from_stream(is);
00115     if(ok) {
00116       ok = FDM_Parse_Tree::parse_tree_to_object(obj, p);
00117     }
00118     if(!ok) {
00119       is.clear(std::ios::badbit);
00120     }
00121     return(is);
00122   }

Here is the call graph for this function:

_Stack_Elt& claraty::FDM_Parse_Tree::top_of_stack (  )  [inline, protected]

Definition at line 133 of file fdm_parse_tree.h.

References _stack.

Referenced by _array_element(), _array_resizable_length(), _begin_array(), _begin_map(), _end(), _io_object(), _map_field(), and io_primitive().

00133                              {
00134     assert(_stack.size());
00135     return _stack.back();
00136   }

void claraty::FDM_Parse_Tree::show_stack (  )  [protected]

Definition at line 44 of file fdm_parse_tree.cc.

References _stack.

Referenced by _array_element(), _array_resizable_length(), _begin_array(), _begin_map(), _end(), _io_object(), _map_field(), and io_primitive().

00045 {
00046   std::cout << "Stack: ";
00047   if (_stack.size() == 0) {
00048     std::cout << "empty\n";
00049     return;
00050   }
00051   for (int i= 0; i< (int)_stack.size(); i++) {
00052     Parse_Tree &pt= _stack[i].pt;
00053     if (pt.is_atom()) {
00054       std::cout << " Atom";
00055     } else if (pt.is_array()) {
00056       std::cout << " Array(" << pt.size() << ")";
00057     } else if (pt.is_map()) {
00058       std::cout << " Map";
00059     } else if (pt.is_null()) {
00060       std::cout << " NULL";
00061     }
00062   }
00063   std::cout << "\n";
00064 }

template<class T1>
bool claraty::FDM_Parse_Tree::type_equal ( const T1 &  x,
const T1 &  y 
) [inline, protected]

Definition at line 140 of file fdm_parse_tree.h.

00140 { return true; }

template<class T1, class T2>
bool claraty::FDM_Parse_Tree::type_equal ( const T1 &  x,
const T2 &  y 
) [inline, protected]

Definition at line 143 of file fdm_parse_tree.h.

00143 { return false; }

template<class T1, class T2>
bool claraty::FDM_Parse_Tree::type_equal (  )  [inline, protected]

Definition at line 146 of file fdm_parse_tree.h.

00146                     {
00147     return type_equal((T1 const *)NULL,
00148                       (T2 const *)NULL);
00149   }

template<class T>
bool claraty::FDM_Parse_Tree::io_primitive ( T &  x  )  [inline, protected]

Definition at line 152 of file fdm_parse_tree.h.

References _break_on_error, claraty::FDM_Stream::_debug, claraty::Parse_Tree::get_value(), claraty::FDM_Stream::is_write(), claraty::FDM_Parse_Tree::_Stack_Elt::pt, claraty::Parse_Tree::set_value(), show_stack(), and top_of_stack().

Referenced by _io_object().

00152                           {
00153     if (is_write()) {
00154       std::ostringstream str;
00155       if (type_equal<T,float>()) {
00156         // Single precision has 23 bits of mantissa (plus implicit one bit)
00157         // log10(2^24)=7.22
00158         str << std::setprecision(8);
00159       } else if (type_equal<T,double>()) {
00160         // Double precision has 52 bits of mantissa (plus implicit one bit)
00161         // log10(2^53)=15.95
00162         str << std::setprecision(16);
00163       } else if (type_equal<T,long double>()) {
00164         // Long double might have 84 bits of mantissa??
00165         // log10(2^85)=25.59
00166         str << std::setprecision(26);
00167       }
00168       str << x;
00169       std::string s(str.str());
00170       top_of_stack().pt.set_value(s);
00171       if (_debug) {
00172         std::cout << "io_primitive: ";
00173         show_stack();
00174       }
00175       return true;
00176     }
00177     else {
00178       bool ok= true;
00179       std::string s= top_of_stack().pt.get_value(&ok);
00180       if (!ok) {
00181         assert(!_break_on_error);
00182         return false;
00183       }
00184       std::istringstream str(s);
00185       str >> x;
00186       if (_debug) {
00187         std::cout << "io_primitive: ";
00188         show_stack();
00189       }
00190       return true;
00191     }
00192   }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( bool &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 194 of file fdm_parse_tree.h.

References io_primitive().

Referenced by _peek_object().

00194 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( unsigned char &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 195 of file fdm_parse_tree.h.

References io_primitive().

00195 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( char &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 196 of file fdm_parse_tree.h.

References io_primitive().

00196 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( unsigned short &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 197 of file fdm_parse_tree.h.

References io_primitive().

00197 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( short &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 198 of file fdm_parse_tree.h.

References io_primitive().

00198 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( unsigned int &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 199 of file fdm_parse_tree.h.

References io_primitive().

00199 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( int &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 200 of file fdm_parse_tree.h.

References io_primitive().

00200 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( unsigned long &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 201 of file fdm_parse_tree.h.

References io_primitive().

00201 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( long &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 202 of file fdm_parse_tree.h.

References io_primitive().

00202 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( unsigned long long &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 203 of file fdm_parse_tree.h.

References io_primitive().

00203 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( long long &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 204 of file fdm_parse_tree.h.

References io_primitive().

00204 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( float &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 205 of file fdm_parse_tree.h.

References io_primitive().

00205 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( double &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 206 of file fdm_parse_tree.h.

References io_primitive().

00206 { return io_primitive(x); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_io_object ( std::string &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 211 of file fdm_parse_tree.h.

References _break_on_error, claraty::FDM_Stream::_debug, claraty::Parse_Tree::get_value(), claraty::FDM_Stream::is_write(), claraty::FDM_Parse_Tree::_Stack_Elt::pt, claraty::Parse_Tree::set_value(), show_stack(), and top_of_stack().

00211                                         {
00212     if (is_write()) {
00213       top_of_stack().pt.set_value(x);
00214       if (_debug) {
00215         std::cout << "io_object(string): ";
00216         show_stack();
00217       }
00218       return true;
00219     } else {
00220       bool ok= true;
00221       // Get the top into a temporary value because if it fails 
00222       // this returns the string 'NULL', and on failure we want to 
00223       // not modify x
00224       std::string val = top_of_stack().pt.get_value(&ok);
00225       if (!ok) {
00226         assert(!_break_on_error);
00227         return false;
00228       }
00229       else {
00230         x=val;
00231       }
00232       if (_debug) {
00233         std::cout << "io_primitive: ";
00234         show_stack();
00235       }
00236       return true;
00237     }
00238   }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_peek_object ( unsigned int &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 240 of file fdm_parse_tree.h.

References _io_object().

00240 { return(_io_object(x)); }

Here is the call graph for this function:

virtual bool claraty::FDM_Parse_Tree::_peek_object ( std::string &  x  )  [inline, protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 241 of file fdm_parse_tree.h.

References _io_object().

00241 { return(_io_object(x)); }

Here is the call graph for this function:

void claraty::FDM_Parse_Tree::_begin_map (  )  [protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 67 of file fdm_parse_tree.cc.

References _break_on_error, claraty::FDM_Stream::_debug, claraty::FDM_Parse_Tree::_Stack_Elt::index, claraty::FDM_Stream::is_read(), claraty::Parse_Tree::make_map(), claraty::FDM_Parse_Tree::_Stack_Elt::pt, show_stack(), and top_of_stack().

00068 {
00069   if (is_read()) {
00070     if (!top_of_stack().pt.is_map()) {
00071       assert(!_break_on_error);
00072     }
00073   } else {
00074     top_of_stack().pt.make_map();
00075     top_of_stack().index= 0;
00076     assert(top_of_stack().pt.size() == 0);
00077     if (_debug) {
00078       std::cout << "_begin_map: ";
00079       show_stack();
00080     }
00081   }
00082 }

Here is the call graph for this function:

void claraty::FDM_Parse_Tree::_begin_array (  )  [protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 85 of file fdm_parse_tree.cc.

References _break_on_error, claraty::FDM_Stream::_debug, claraty::FDM_Parse_Tree::_Stack_Elt::index, claraty::FDM_Stream::is_read(), claraty::Parse_Tree::make_array(), claraty::FDM_Parse_Tree::_Stack_Elt::pt, show_stack(), and top_of_stack().

00086 {
00087   if (is_read()) {
00088     if (!top_of_stack().pt.is_array()) {
00089       assert(!_break_on_error);
00090     }
00091   } else {
00092     // TODO: record size and check at end of array
00093     top_of_stack().pt.make_array();
00094     top_of_stack().index= 0;
00095     assert(top_of_stack().pt.size() == 0);
00096     if (_debug) {
00097       std::cout << "_begin_array: ";
00098       show_stack();
00099     }
00100   }
00101 }

Here is the call graph for this function:

bool claraty::FDM_Parse_Tree::_array_resizable_length ( int &  size  )  [protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 104 of file fdm_parse_tree.cc.

References _break_on_error, claraty::FDM_Stream::_debug, claraty::FDM_Stream::is_read(), claraty::FDM_Parse_Tree::_Stack_Elt::pt, show_stack(), claraty::Parse_Tree::size(), and top_of_stack().

00105 {
00106   if (!top_of_stack().pt.is_array()) {
00107     assert(!_break_on_error);
00108     return(false);
00109   }
00110   if (is_read()) {
00111     size= top_of_stack().pt.size();
00112   } else {
00113     // Just assert that this is called before any elements
00114     // We're not actually going to check the number
00115     assert(top_of_stack().pt.size() == 0);
00116     if (_debug) {
00117       std::cout << "_begin_array_resizable: ";
00118       show_stack();
00119     }
00120   }
00121   return(true);
00122 }

Here is the call graph for this function:

bool claraty::FDM_Parse_Tree::_array_element (  )  [protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 125 of file fdm_parse_tree.cc.

References _break_on_error, claraty::FDM_Stream::_debug, _stack, claraty::Parse_Tree::get_element(), claraty::FDM_Stream::is_write(), claraty::FDM_Parse_Tree::_Stack_Elt::pt, claraty::Parse_Tree::set_element(), show_stack(), and top_of_stack().

00126 {
00127   while (!top_of_stack().pt.is_array()) _stack.pop_back();
00128   bool ok= true;
00129   if (!top_of_stack().pt.is_array()) {
00130     assert(0);
00131     return false;
00132   }
00133   Parse_Tree elt;
00134   if (is_write()) {
00135     top_of_stack().pt.set_element(top_of_stack().index++, elt);
00136   } else {
00137     elt= top_of_stack().pt.get_element(top_of_stack().index++, &ok);
00138     assert(ok || !_break_on_error);
00139   }
00140   _stack.push_back(elt);
00141   if (_debug) {
00142     std::cout << "_array_element: ";
00143     show_stack();
00144   }
00145   return true;
00146 }

Here is the call graph for this function:

void claraty::FDM_Parse_Tree::_end (  )  [protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 149 of file fdm_parse_tree.cc.

References _break_on_error, claraty::FDM_Stream::_debug, _stack, claraty::Parse_Tree::is_array(), claraty::FDM_Parse_Tree::_Stack_Elt::pt, show_stack(), and top_of_stack().

00150 {
00151   while (!top_of_stack().pt.is_map() && !top_of_stack().pt.is_array()) 
00152     _stack.pop_back();
00153   if (_stack.size() > 1) {
00154     _stack.pop_back();
00155     if (_debug) {
00156       std::cout << "_end: ";
00157       show_stack();
00158     }
00159   } else {
00160     if (_debug) {
00161       std::cout << "_end: ";
00162       show_stack();
00163     }
00164     assert(!_break_on_error);
00165   }
00166 }

Here is the call graph for this function:

bool claraty::FDM_Parse_Tree::_map_field ( const char *  name  )  [protected, virtual]

Implements claraty::FDM_Stream.

Definition at line 169 of file fdm_parse_tree.cc.

References _break_on_error, claraty::FDM_Stream::_debug, _stack, claraty::Parse_Tree::get_field(), claraty::FDM_Stream::is_write(), claraty::FDM_Parse_Tree::_Stack_Elt::pt, claraty::Parse_Tree::set_field(), show_stack(), and top_of_stack().

00170 {
00171   bool ok= true;
00172   while (!top_of_stack().pt.is_map()) _stack.pop_back();
00173   if (name) {
00174     Parse_Tree field;
00175     if (is_write()) top_of_stack().pt.set_field(name, field);
00176     else {
00177       field= top_of_stack().pt.get_field(name, &ok);
00178       assert(ok || !_break_on_error);
00179     }
00180     _stack.push_back(field);
00181   } else {
00182     _stack.push_back(top_of_stack());
00183   }
00184   if (_debug) {
00185     std::cout << "_map_field: ";
00186     show_stack();
00187   }
00188   return ok;
00189 }

Here is the call graph for this function:

bool claraty::FDM_Stream::is_read (  )  [inline, inherited]

virtual bool claraty::FDM_Stream::eof (  )  [inline, virtual, inherited]

Reimplemented in claraty::File_FDM_Parse_Tree.

Definition at line 82 of file fdm.h.

00082 { return false; }

virtual bool claraty::FDM_Stream::flush (  )  [inline, virtual, inherited]

Reimplemented in claraty::File_FDM_Parse_Tree.

Definition at line 86 of file fdm.h.

00086 { return true; }

void claraty::FDM_Stream::debug ( int  debugging_level = 1  )  [inline, inherited]

Definition at line 88 of file fdm.h.

References claraty::FDM_Stream::_debug.

00088                                     {
00089     _debug= debugging_level;
00090   }

template<class T>
bool claraty::FDM_Stream::write ( const T &  x  )  [inline, inherited]

Definition at line 93 of file fdm.h.

References claraty::FDM_Stream::_end_topform(), claraty::FDM_Stream::_io_object(), claraty::FDM_Stream::_start_topform(), and claraty::FDM_Stream::is_write().

Referenced by object_to_parse_tree(), object_to_string(), claraty::File_FDM_Parse_Tree::write_object(), and write_object().

00093                          {
00094     assert(is_write());
00095     bool ok = _start_topform(typeid(T).name());
00096     ok &= _io_object((T&)x);
00097     ok &= _end_topform();
00098     return(ok);
00099   }

Here is the call graph for this function:

template<class T>
bool claraty::FDM_Stream::read ( T &  x  )  [inline, inherited]

Definition at line 102 of file fdm.h.

References claraty::FDM_Stream::_end_topform(), claraty::FDM_Stream::_io_object(), claraty::FDM_Stream::_start_topform(), and claraty::FDM_Stream::is_read().

Referenced by parse_tree_to_object(), and claraty::File_FDM_Parse_Tree::read_object().

00102                   {
00103     assert(is_read());
00104     bool ok = _start_topform(typeid(T).name());
00105     ok &= _io_object((T&)x);
00106     ok &= _end_topform();
00107     return(ok);
00108   }

Here is the call graph for this function:

virtual bool claraty::FDM_Stream::_start_topform ( const char *  type_name  )  [inline, protected, virtual, inherited]

Reimplemented in claraty::File_FDM_Parse_Tree.

Definition at line 120 of file fdm.h.

Referenced by claraty::File_FDM_Parse_Tree::_start_topform(), claraty::FDM_Stream::read(), and claraty::FDM_Stream::write().

00120                                                      {
00121     return true;
00122   }

virtual bool claraty::FDM_Stream::_end_topform (  )  [inline, protected, virtual, inherited]

Reimplemented in claraty::File_FDM_Parse_Tree.

Definition at line 123 of file fdm.h.

Referenced by claraty::FDM_Stream::read(), and claraty::FDM_Stream::write().

00123                               {
00124     return true;
00125   }

bool claraty::FDM_Stream::_io_object ( std::vector< bool >::reference  bit_ref  )  [inline, protected, inherited]

Definition at line 146 of file fdm.h.

Referenced by claraty::FDM_Array::element(), claraty::FDM_Map::field(), claraty::FDM_Stream::read(), claraty::FDM_Untyped_Node::value(), and claraty::FDM_Stream::write().

00146                                                     {
00147     bool b = bit_ref;
00148     bool ret = _io_object(b);
00149     bit_ref = b;
00150     return ret;
00151   }

template<class T>
bool claraty::FDM_Stream::_io_object ( T &  x  )  [inline, protected, inherited]

Definition at line 180 of file fdm.h.

References claraty::FDM_Stream::FDM_Node, and claraty::io_object().

00180 { return io_object(FDM_Node(*this), x); }

Here is the call graph for this function:

FDM_Untyped_Node claraty::FDM_Stream::_map_field_node ( const char *  name  )  [protected, inherited]

Definition at line 71 of file fdm.cc.

References claraty::FDM_Stream::_map_field(), and claraty::FDM_Stream::FDM_Untyped_Node.

Referenced by claraty::FDM_Map::field_node().

00072 {
00073   _map_field(name);
00074   return FDM_Untyped_Node(*this);
00075 }

Here is the call graph for this function:

FDM_Untyped_Node claraty::FDM_Stream::_array_element_node (  )  [protected, inherited]

Definition at line 77 of file fdm.cc.

References claraty::FDM_Stream::_array_element(), and claraty::FDM_Stream::FDM_Untyped_Node.

Referenced by claraty::FDM_Array::element_node().

00078 {
00079   _array_element();
00080   return FDM_Untyped_Node(*this);
00081 }

Here is the call graph for this function:

void claraty::FDM_Stream::_pop_node (  )  [protected, inherited]

Definition at line 84 of file fdm.cc.

References claraty::FDM_Stream::_debug, claraty::FDM_Stream::_end(), and claraty::FDM_Stream::_stack.

Referenced by claraty::FDM_Stream::_unref_node(), and claraty::FDM_Stream::_unwind_to_node().

00085 {
00086   assert(_stack.size());
00087   if (_debug) {
00088     fprintf(stderr, "in pop_node, removing id=%d, level=%d from stack\n",
00089             _stack.back().id, _stack.size()-1);
00090   }
00091   _stack.pop_back();
00092   _end();
00093 }

Here is the call graph for this function:

void claraty::FDM_Stream::_unwind_to_node ( FDM_Node node  )  [protected, inherited]

Definition at line 95 of file fdm.cc.

References claraty::FDM_Stream::_debug, claraty::FDM_Stream::_find_node(), claraty::FDM_Stream::_pop_node(), claraty::FDM_Stream::_stack, and claraty::fdm_error().

Referenced by claraty::FDM_Array::element_node(), claraty::FDM_Map::field(), claraty::FDM_Map::field_node(), and claraty::FDM_Map::peekfield().

00096 {
00097   int index= _find_node(node);
00098   if (index == -1) fdm_error("Attempt to add to deleted node");
00099   if (_debug) fprintf(stderr, "in unwind, removing %d items from stack\n",
00100                       _stack.size() - (index+1));
00101   while (_stack.size() > (unsigned)index+1) _pop_node();
00102 }

Here is the call graph for this function:

void claraty::FDM_Stream::_ref_node ( FDM_Node node  )  [protected, inherited]

Definition at line 104 of file fdm.cc.

References claraty::FDM_Stream::_debug, claraty::FDM_Stream::_find_node(), claraty::FDM_Node::_id, claraty::FDM_Stream::_stack, and claraty::fdm_error().

Referenced by claraty::FDM_Node::FDM_Node().

00105 {
00106   int index= _find_node(node);
00107   if (index == -1) fdm_error("Attempt to reference deleted node");
00108   _stack[index].refcnt++;
00109   if (_debug) fprintf(stderr, "incrementing ref(%d) to %d\n",
00110                       node._id, _stack[index].refcnt);
00111 }

Here is the call graph for this function:

void claraty::FDM_Stream::_unref_node ( FDM_Node node  )  [protected, inherited]

Definition at line 113 of file fdm.cc.

References claraty::FDM_Stream::_debug, claraty::FDM_Stream::_find_node(), claraty::FDM_Node::_id, claraty::FDM_Stream::_pop_node(), and claraty::FDM_Stream::_stack.

Referenced by claraty::FDM_Node::~FDM_Node().

00114 {
00115   int index= _find_node(node);
00116   if (index == -1) return;
00117   _stack[index].refcnt--;
00118   if (_debug) fprintf(stderr, "decrementing ref(%d) to %d\n",
00119                       node._id, _stack[index].refcnt);
00120   assert(_stack[index].refcnt>=0);
00121   if (!_stack[index].refcnt) {
00122     if (_debug) fprintf(stderr, "  removing %d items from stack\n",
00123                         _stack.size()-index);
00124     while (_stack.size() > (unsigned)index) _pop_node();
00125   }
00126 }

Here is the call graph for this function:

void claraty::FDM_Stream::_push_node ( FDM_Node node  )  [protected, inherited]

Definition at line 128 of file fdm.cc.

References claraty::FDM_Stream::_debug, claraty::FDM_Node::_id, claraty::FDM_Stream::_id, claraty::FDM_Node::_level, claraty::FDM_Stream::_stack, claraty::FDM_Stream::nodeinfo_str::id, and claraty::FDM_Stream::nodeinfo_str::refcnt.

Referenced by claraty::FDM_Map::_begin_map(), and claraty::FDM_Array::FDM_Array().

00129 {
00130   _id++;
00131   nodeinfo_str ni;
00132   ni.id= node._id= _id++;
00133   ni.refcnt= 1;
00134   node._level= _stack.size();
00135   _stack.push_back(ni);
00136   if (_debug) fprintf(stderr, "pushing node id %d, level %d\n", 
00137                       ni.id, node._level);
00138 }

int claraty::FDM_Stream::_find_node ( FDM_Node node  )  [protected, inherited]

Definition at line 140 of file fdm.cc.

References claraty::FDM_Node::_id, claraty::FDM_Node::_level, and claraty::FDM_Stream::_stack.

Referenced by claraty::FDM_Stream::_ref_node(), claraty::FDM_Stream::_unref_node(), and claraty::FDM_Stream::_unwind_to_node().

00141 {
00142   int index= node._level;
00143   if (index >= static_cast<long>(_stack.size()) ||
00144       _stack[index].id != node._id)
00145     return -1;
00146   return index;
00147 }


Member Data Documentation

int claraty::FDM_Stream::_id [protected, inherited]

Definition at line 207 of file fdm.h.

Referenced by claraty::FDM_Stream::_push_node().

bool claraty::FDM_Stream::_write [protected, inherited]

Definition at line 208 of file fdm.h.

Referenced by claraty::FDM_Stream::is_read(), and claraty::FDM_Stream::is_write().


The documentation for this class was generated from the following files: