Qore Programming Language  0.8.7
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
BinaryNode.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  BinaryNode.h
4 
5  Qore Programming Language
6 
7  Copyright 2003 - 2013 David Nichols
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23 
24 #ifndef _QORE_BINARYNODE_H
25 
26 #define _QORE_BINARYNODE_H
27 
28 #include <qore/AbstractQoreNode.h>
29 
31 
34 private:
36  void *ptr;
38  qore_size_t len;
39 
40  // not yet implemented
41  DLLLOCAL BinaryNode(const BinaryNode&);
42  DLLLOCAL BinaryNode& operator=(const BinaryNode&);
43 
44 protected:
46  DLLEXPORT virtual ~BinaryNode();
47 
48 public:
50 
53  DLLEXPORT BinaryNode(void *p = 0, qore_size_t size = 0);
54 
56 
58  DLLEXPORT virtual bool getAsBoolImpl() const;
59 
61 
67  DLLEXPORT virtual int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const;
68 
70 
77  DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, class ExceptionSink *xsink) const;
78 
79  DLLEXPORT virtual class AbstractQoreNode *realCopy() const;
80 
82 
86  DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
87 
89 
93  DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
94 
96  DLLEXPORT virtual const char *getTypeName() const;
97 
99  DLLLOCAL virtual AbstractQoreNode *parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo);
100 
102  DLLEXPORT int compare(const BinaryNode *obj) const;
103 
105  DLLEXPORT qore_size_t size() const;
106 
108  DLLEXPORT bool empty() const;
109 
111 
114  DLLEXPORT BinaryNode *copy() const;
115 
117  DLLEXPORT const void *getPtr() const;
118 
120  DLLEXPORT void append(const void *nptr, qore_size_t size);
121 
123  DLLEXPORT void append(const BinaryNode *b);
124 
126  DLLEXPORT void append(const BinaryNode &b);
127 
129  DLLEXPORT void prepend(const void *nptr, qore_size_t size);
130 
132 
137  DLLEXPORT void *giveBuffer();
138 
140 
146  DLLEXPORT int preallocate(qore_size_t size);
147 
149 
154  DLLEXPORT int setSize(qore_size_t size);
155 
157  DLLEXPORT void clear();
158 
160  DLLLOCAL static const char *getStaticTypeName() {
161  return "binary";
162  }
163 
165  DLLLOCAL static qore_type_t getStaticTypeCode() {
166  return NT_BINARY;
167  }
168 };
169 
171 
172 #endif // _QORE_BINARYNODE_H