7 #define WIN32_LEAN_AND_MEAN 60 Stream (
void) { state =
'-'; type =
STRM_void; filename = NULL; str_file = NULL; str_tixel = NULL; str_string = NULL; }
62 Stream (
Stream_type tp) { state =
'-'; type = tp; filename = NULL; str_file = NULL; str_tixel = NULL; str_string = NULL; }
64 Stream (FILE *stream) { state =
'-'; type =
STRM_file; filename = NULL; str_file = stream; str_tixel = NULL; str_string = NULL; }
65 Stream (
XMLNode *stream) { state =
'-'; type =
STRM_tixel; filename = NULL; str_file = NULL; str_tixel = stream; str_string = NULL; }
66 Stream (
const char *stream) { state =
'-'; type =
STRM_string; filename = NULL; str_file = NULL; str_tixel = NULL; str_string = stream; }
77 if (state !=
'-')
errol;
79 if (rw[1] !=
'\0')
errol;
80 if (*rw !=
'r' && *rw !=
'w')
errol;
83 if (filename)
delete [] filename;
84 filename = fn; fn = NULL;
89 if (state ==
'w') this->str_tixel = node;
90 else if (state ==
'r')
errol;
94 if (*rw !=
'r' || node)
errol;
96 FILE *in =
_openFileN(
"rb", filename, filename);
97 char c = getc(in); ungetc(c, in);
99 if (c==
'#') { type =
STRM_file; str_file = in; }
104 else _errorr2 (
"File %s doesnot start neither with character '#' nor '<'", filename);
108 case STRM_string:
errol;
break;
109 default:
_errorr (
"unsuported stream type");
116 case STRM_file: fclose (str_file);
break;
119 else if (state ==
'r') ;
124 case STRM_string:
errol;
break;
125 default:
_errorr (
"unsuported stream type");
135 void redefine (FILE *stream) { type =
STRM_file; str_file = stream; str_tixel = NULL; str_string = NULL; }
137 void redefine (
const char *stream) { type =
STRM_string; str_file = NULL; str_tixel = NULL; str_string = stream; }
146 const char *
string(
void) { check_type(STRM_string);
return str_string;}
147 const char **
pstring(
void){ check_type(STRM_string);
return &str_string;}
153 bool isString (
void) {
return (type == STRM_string); }
167 _errorr (
"wrong type of Stream"); }
190 template <
class ArgType>
193 if (!ST_scan_expected_number (src, expctd))
196 #define ST_scan_expected_number_exit(_1,_2,_3) ST_scan_expected_number_FL (__FILE__, __LINE__, _1,_2,_3) 214 const char *
XP_giveDAtext (
const XMLNode *xelem,
int n,
bool last,
const char *format,
const char *type,
const char *name,
int *noc=NULL);
219 #endif // GELIB_TIXY_H
Stream(FILE *stream)
CONSTRUCTOR.
#define _openFileN(_1, _2, _3)
void XP_check_expected_attribute(const XMLNode *xelem, const char *name, const char *value)
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
long GP_scan_line(Stream *stream, char *dest)
... line; return value is length of the line
Stream(const char *stream)
const XMLElement * XP_give_unique_expected_elem(const XMLNode *xelem, const char *name, bool uniq)
XMLDocument * tix_doc(void)
long GP_scan_line_alloc(Stream *stream, char *&dest)
... line; return value is length of the line; dest is NULL and allocated here
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
The element is a container class.
void open(Stream_type t, const char *rw, const char *&fn, XMLNode *node=NULL)
*** SET ***
bool ST_scan_expected_number(Stream *src, long expctd)
... number and compare with expected one
void redefine(XMLNode *stream)
Stream_type give_type(void)
Stream(Stream_type tp)
CONSTRUCTOR.
FILE * file(void)
*** GET ***
bool ST_scan_number(Stream *src, int &dest)
*** *** *** *** TINYXML FCE *** *** *** ***
A Document binds together all the functionality.
void check_type(Stream_type tp)
XMLError SaveFile(const char *filename, bool compact=false)
Save the XML file to disk.
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Stream_type
*** *** *** *** CLASS STREAM *** *** *** ***
XMLNode is a base class for every object that is in the XML Document Object Model (DOM)...
void errorr_expected(const char *file, int line, const char *msg, const char *expctd, const char *src)
*** *** *** *** STRING PROCESSING *** *** *** *** src pointer is always shifted over the skipped/sc...
const char * string(void)
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
void ST_scan_expected_number_FL(const char *file, int line, Stream *src, ArgType expctd, const char *msg)
... number and compare with expected one, exit if false
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
virtual ~Stream()
DESTRUCTOR.
void checkin_type(Stream_type tp)
long GP_scan_word(Stream *stream, char *dest)
... word; return value is length of the word
const char * XP_giveDAtext(const XMLNode *xelem, int n, bool last, const char *format, const char *type, const char *name, int *noc)
void redefine(FILE *stream)
void redefine(const char *stream)
XMLDocument * openTXdcPNSS(const char *path, const char *name, const char *suff, const char *suff2)
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
XMLDocument * openTXdcPN(const char *path, const char *name)
*** *** *** *** TINYXML FCE *** *** *** ***
bool ST_scan_array(Stream *src, int n, int *dest)
scan/copy array of numbers from src to dest, src pointer is shifted over the field ...
const char ** pstring(void)
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
void skip_commnet(void)
if this XMLnode is XMLComment, skip to next noncomment