claraty::FDM_Stream Class Reference
#include <fdm.h>
Inheritance diagram for claraty::FDM_Stream:

Public Member Functions | |
| virtual | ~FDM_Stream () |
| 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) |
Protected Member Functions | |
| FDM_Stream (FDM::Direction dir) | |
| virtual bool | _start_topform (const char *type_name) |
| virtual bool | _end_topform () |
| virtual bool | _map_field (const char *name)=0 |
| virtual bool | _array_element ()=0 |
| virtual void | _begin_array ()=0 |
| virtual void | _begin_map ()=0 |
| virtual bool | _array_resizable_length (int &size)=0 |
| virtual void | _end ()=0 |
| bool | _io_object (std::vector< bool >::reference bit_ref) |
| virtual bool | _io_object (bool &x)=0 |
| virtual bool | _io_object (unsigned char &x)=0 |
| virtual bool | _io_object (char &x)=0 |
| virtual bool | _io_object (unsigned short &x)=0 |
| virtual bool | _io_object (short &x)=0 |
| virtual bool | _io_object (unsigned int &x)=0 |
| virtual bool | _io_object (int &x)=0 |
| virtual bool | _io_object (unsigned long &x)=0 |
| virtual bool | _io_object (long &x)=0 |
| virtual bool | _io_object (unsigned long long &x)=0 |
| virtual bool | _io_object (long long &x)=0 |
| virtual bool | _io_object (float &x)=0 |
| virtual bool | _io_object (double &x)=0 |
| virtual bool | _io_object (std::string &x)=0 |
| virtual bool | _peek_object (unsigned int &x)=0 |
| virtual bool | _peek_object (std::string &x)=0 |
| FDM_Untyped_Node | _map_field_node (const char *name) |
| FDM_Untyped_Node | _array_element_node () |
| template<class T> | |
| bool | _io_object (T &x) |
| 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< nodeinfo_str > | _stack |
| int | _id |
| bool | _write |
| int | _debug |
Friends | |
| class | FDM_Map |
| class | FDM_Array |
| class | FDM_Untyped_Node |
| class | FDM_Node |
Classes | |
| struct | nodeinfo_str |
Detailed Description
Definition at line 70 of file fdm.h.
Constructor & Destructor Documentation
| virtual claraty::FDM_Stream::~FDM_Stream | ( | ) | [inline, virtual] |
| claraty::FDM_Stream::FDM_Stream | ( | FDM::Direction | dir | ) | [inline, protected] |
Member Function Documentation
| bool claraty::FDM_Stream::is_read | ( | ) | [inline] |
Definition at line 78 of file fdm.h.
References _write.
Referenced by claraty::FDM_Parse_Tree::_array_resizable_length(), claraty::FDM_Parse_Tree::_begin_array(), claraty::FDM_Parse_Tree::_begin_map(), claraty::File_FDM_Parse_Tree::_start_topform(), claraty::FDM_Array::is_read(), claraty::FDM_Map::is_read(), and read().
00078 { return !_write; }
| bool claraty::FDM_Stream::is_write | ( | ) | [inline] |
Definition at line 79 of file fdm.h.
References _write.
Referenced by claraty::FDM_Parse_Tree::_array_element(), claraty::File_FDM_Parse_Tree::_end_topform(), claraty::FDM_Parse_Tree::_io_object(), claraty::FDM_Parse_Tree::_map_field(), claraty::File_FDM_Parse_Tree::close(), claraty::FDM_Parse_Tree::io_primitive(), claraty::FDM_Array::is_write(), claraty::FDM_Map::is_write(), and write().
00079 { return _write; }
| virtual bool claraty::FDM_Stream::eof | ( | ) | [inline, virtual] |
| virtual bool claraty::FDM_Stream::flush | ( | ) | [inline, virtual] |
| void claraty::FDM_Stream::debug | ( | int | debugging_level = 1 |
) | [inline] |
| bool claraty::FDM_Stream::write | ( | const T & | x | ) | [inline] |
Definition at line 93 of file fdm.h.
References _end_topform(), _io_object(), _start_topform(), and is_write().
Referenced by claraty::FDM_Parse_Tree::object_to_parse_tree(), claraty::FDM_Parse_Tree::object_to_string(), claraty::File_FDM_Parse_Tree::write_object(), and claraty::FDM_Parse_Tree::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:

| bool claraty::FDM_Stream::read | ( | T & | x | ) | [inline] |
Definition at line 102 of file fdm.h.
References _end_topform(), _io_object(), _start_topform(), and is_read().
Referenced by claraty::FDM_Parse_Tree::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] |
Reimplemented in claraty::File_FDM_Parse_Tree.
Definition at line 120 of file fdm.h.
Referenced by claraty::File_FDM_Parse_Tree::_start_topform(), read(), and write().
| virtual bool claraty::FDM_Stream::_end_topform | ( | ) | [inline, protected, virtual] |
Reimplemented in claraty::File_FDM_Parse_Tree.
Definition at line 123 of file fdm.h.
Referenced by read(), and write().
| virtual bool claraty::FDM_Stream::_map_field | ( | const char * | name | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
Referenced by _map_field_node(), claraty::FDM_Map::field(), and claraty::FDM_Map::peekfield().
| virtual bool claraty::FDM_Stream::_array_element | ( | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
Referenced by _array_element_node(), and claraty::FDM_Array::element().
| virtual void claraty::FDM_Stream::_begin_array | ( | ) | [protected, pure virtual] |
| virtual void claraty::FDM_Stream::_begin_map | ( | ) | [protected, pure virtual] |
| virtual bool claraty::FDM_Stream::_array_resizable_length | ( | int & | size | ) | [protected, pure virtual] |
| virtual void claraty::FDM_Stream::_end | ( | ) | [protected, pure virtual] |
| bool claraty::FDM_Stream::_io_object | ( | std::vector< bool >::reference | bit_ref | ) | [inline, protected] |
Definition at line 146 of file fdm.h.
Referenced by claraty::FDM_Array::element(), claraty::FDM_Map::field(), read(), claraty::FDM_Untyped_Node::value(), and write().
00146 { 00147 bool b = bit_ref; 00148 bool ret = _io_object(b); 00149 bit_ref = b; 00150 return ret; 00151 }
| virtual bool claraty::FDM_Stream::_io_object | ( | bool & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | unsigned char & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | char & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | unsigned short & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | short & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | unsigned int & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | int & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | unsigned long & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | long & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | unsigned long long & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | long long & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | float & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | double & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_io_object | ( | std::string & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| virtual bool claraty::FDM_Stream::_peek_object | ( | unsigned int & | x | ) | [protected, pure virtual] |
| virtual bool claraty::FDM_Stream::_peek_object | ( | std::string & | x | ) | [protected, pure virtual] |
Implemented in claraty::FDM_Parse_Tree.
| FDM_Untyped_Node claraty::FDM_Stream::_map_field_node | ( | const char * | name | ) | [protected] |
Definition at line 71 of file fdm.cc.
References _map_field(), and 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] |
Definition at line 77 of file fdm.cc.
References _array_element(), and 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:

| bool claraty::FDM_Stream::_io_object | ( | T & | x | ) | [inline, protected] |
| void claraty::FDM_Stream::_pop_node | ( | ) | [protected] |
Definition at line 84 of file fdm.cc.
References _debug, _end(), and _stack.
Referenced by _unref_node(), and _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] |
Definition at line 95 of file fdm.cc.
References _debug, _find_node(), _pop_node(), _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] |
Definition at line 104 of file fdm.cc.
References _debug, _find_node(), claraty::FDM_Node::_id, _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] |
Definition at line 113 of file fdm.cc.
References _debug, _find_node(), claraty::FDM_Node::_id, _pop_node(), and _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] |
Definition at line 128 of file fdm.cc.
References _debug, claraty::FDM_Node::_id, _id, claraty::FDM_Node::_level, _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] |
Definition at line 140 of file fdm.cc.
References claraty::FDM_Node::_id, claraty::FDM_Node::_level, and _stack.
Referenced by _ref_node(), _unref_node(), and _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 }
Friends And Related Function Documentation
friend class FDM_Untyped_Node [friend] |
friend class FDM_Node [friend] |
Member Data Documentation
std::vector<nodeinfo_str> claraty::FDM_Stream::_stack [protected] |
Reimplemented in claraty::FDM_Parse_Tree.
Definition at line 204 of file fdm.h.
Referenced by _find_node(), _pop_node(), _push_node(), _ref_node(), _unref_node(), and _unwind_to_node().
int claraty::FDM_Stream::_id [protected] |
bool claraty::FDM_Stream::_write [protected] |
int claraty::FDM_Stream::_debug [protected] |
Definition at line 209 of file fdm.h.
Referenced by claraty::FDM_Parse_Tree::_array_element(), claraty::FDM_Parse_Tree::_array_resizable_length(), claraty::FDM_Parse_Tree::_begin_array(), claraty::FDM_Parse_Tree::_begin_map(), claraty::FDM_Parse_Tree::_end(), claraty::FDM_Parse_Tree::_io_object(), claraty::FDM_Parse_Tree::_map_field(), _pop_node(), _push_node(), _ref_node(), _unref_node(), _unwind_to_node(), debug(), and claraty::FDM_Parse_Tree::io_primitive().
The documentation for this class was generated from the following files:
