/[pearpc]/src/tools/store.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /src/tools/store.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (show annotations)
Thu Sep 6 16:48:55 2007 UTC (11 years, 10 months ago) by dpavlin
File MIME type: text/plain
File size: 5103 byte(s)
more forgotten files
1 asfasfasf as f asf asfasf as f asdf
2 /*
3 * HT Editor
4 * store.h
5 *
6 * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #ifndef STORE_H
23 #define STORE_H
24
25 #include "data.h"
26 #include "sys/types.h"
27
28 typedef Object *(*object_builder)();
29
30 #include "stream.h"
31 #include "except.h"
32
33 class ObjectNotRegisteredException: public MsgfException {
34 ObjectID mID;
35 public:
36 ObjectNotRegisteredException(ObjectID aID);
37 };
38
39 class ObjectStreamInter: public ObjectStream {
40 public:
41 ObjectStreamInter(Stream *s, bool own_stream);
42 /* extends ObjectStream */
43 virtual void getObject(Object *&object, const char *name, ObjectID id = OBJID_INVALID);
44 virtual void putObject(const Object *object, const char *name, ObjectID id = OBJID_INVALID);
45 };
46
47 class ObjectStreamBin: public ObjectStreamInter {
48 public:
49 ObjectStreamBin(Stream *s, bool own_s);
50 /* extends ObjectStream */
51 virtual void getBinary(void *buf, uint size, const char *desc);
52 virtual bool getBool(const char *desc);
53 virtual uint64 getInt(uint size, const char *desc);
54 virtual char * getString(const char *desc);
55 virtual byte * getLenString(int &length, const char *desc);
56
57 virtual void putBinary(const void *mem, uint size, const char *desc);
58 virtual void putBool(bool b, const char *desc);
59 virtual void putComment(const char *comment);
60 virtual void putCommentf(const char *comment_format, ...);
61 virtual void putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint = OS_FMT_DEC);
62 virtual void putSeparator();
63 virtual void putString(const char *string, const char *desc);
64 virtual void putLenString(const byte *string, int length, const char *desc);
65 };
66
67 class ObjectStreamText: public ObjectStreamInter {
68 protected:
69 char cur;
70 int line;
71 int errorline;
72 int indent;
73 public:
74
75 ObjectStreamText(Stream *s, bool own_stream);
76 /* extends ObjectStreamInter */
77 virtual void getObject(Object *&object, const char *name, ObjectID id = OBJID_INVALID);
78 virtual void putObject(const Object *object, const char *name, ObjectID id = OBJID_INVALID);
79 /* extends ObjectStream */
80 virtual void getBinary(void *buf, uint size, const char *desc);
81 virtual bool getBool(const char *desc);
82 virtual uint64 getInt(uint size, const char *desc);
83 virtual char * getString(const char *desc);
84 virtual byte * getLenString(int &length, const char *desc);
85
86 virtual void putBinary(const void *mem, uint size, const char *desc);
87 virtual void putBool(bool b, const char *desc);
88 virtual void putComment(const char *comment);
89 virtual void putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint = OS_FMT_DEC);
90 virtual void putSeparator();
91 virtual void putString(const char *string, const char *desc);
92 virtual void putLenString(const byte *string, int length, const char *desc);
93
94 void setSyntaxError();
95 int getErrorLine();
96 private:
97 /* io */
98 void expect(char c);
99 void skipWhite();
100 char readChar();
101 void readDesc(const char *desc);
102
103
104 void putDesc(const char *desc);
105 void putIndent();
106 void putChar(char c);
107 void putS(const char *s);
108 };
109
110 /*
111 * ObjectStreamNative View:set/getData() methods
112 * (endian-dependend)
113 */
114
115 #define DATABUF_BOOL(name) bool name __htpacked
116 #define DATABUF_UINT(name) uint name __htpacked
117 #define DATABUF_PTR(type, name) type* name __htpacked
118
119 class ObjectStreamNative: public ObjectStream {
120 protected:
121 bool duplicate;
122 Array allocd;
123
124 void *duppa(const void *p, int size);
125 public:
126 ObjectStreamNative(Stream *s, bool own_s, bool duplicate);
127 /* extends ObjectStream */
128 virtual void getBinary(void *buf, uint size, const char *desc);
129 virtual bool getBool(const char *desc);
130 virtual uint64 getInt(uint size, const char *desc);
131 virtual void getObject(Object *&object, const char *name, ObjectID id = OBJID_INVALID);
132 virtual char * getString(const char *desc);
133 virtual byte * getLenString(int &length, const char *desc);
134
135 virtual void putBinary(const void *mem, uint size, const char *desc);
136 virtual void putBool(bool b, const char *desc);
137 virtual void putComment(const char *comment);
138 virtual void putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint = OS_FMT_DEC);
139 virtual void putObject(const Object *object, const char *name, ObjectID id = OBJID_INVALID);
140 virtual void putSeparator();
141 virtual void putString(const char *string, const char *desc);
142 virtual void putLenString(const byte *string, int length, const char *desc);
143 };
144
145 #endif

  ViewVC Help
Powered by ViewVC 1.1.26