Qore Programming Language: include/qore/BinaryNode.h (6585) Source File

Qore Programming Language 0.8.11

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

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
33 class BinaryNode : public SimpleValueQoreNode {
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 DLLLOCAL void checkOffset(qore_offset_t& offset) const;
49 DLLLOCAL void checkOffset(qore_offset_t& offset, qore_offset_t& num) const;
50
51 public:
53
56 DLLEXPORT BinaryNode(void *p = 0, qore_size_t size = 0);
57
59
61 DLLEXPORT virtual bool getAsBoolImpl() const;
62
64
70 DLLEXPORT virtual int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const;
71
73
80 DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, class ExceptionSink *xsink) const;
81
82 DLLEXPORT virtual class AbstractQoreNode *realCopy() const;
83
85
89 DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
90
92
96 DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
97
99 DLLEXPORT virtual const char *getTypeName() const;
100
102 DLLLOCAL virtual AbstractQoreNode *parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo);
103
105 DLLEXPORT int compare(const BinaryNode *obj) const;
106
108 DLLEXPORT qore_size_t size() const;
109
111 DLLEXPORT bool empty() const;
112
114
117 DLLEXPORT BinaryNode *copy() const;
118
120 DLLEXPORT const void *getPtr() const;
121
123 DLLEXPORT void append(const void *nptr, qore_size_t size);
124
126 DLLEXPORT void append(const BinaryNode *b);
127
129 DLLEXPORT void append(const BinaryNode &b);
130
132 DLLEXPORT void prepend(const void *nptr, qore_size_t size);
133
135
140 DLLEXPORT void *giveBuffer();
141
143
149 DLLEXPORT int preallocate(qore_size_t size);
150
152
157 DLLEXPORT int setSize(qore_size_t size);
158
160
166 DLLEXPORT void splice(qore_offset_t offset, qore_offset_t length, BinaryNode* extract = 0);
167
169
177 DLLEXPORT void splice(qore_offset_t offset, qore_offset_t length, const void* data, qore_size_t data_len, BinaryNode* extract = 0);
178
180
186 DLLEXPORT int substr(BinaryNode& b, qore_offset_t offset) const;
187
189
196 DLLEXPORT int substr(BinaryNode& b, qore_offset_t offset, qore_offset_t length) const;
197
199 DLLEXPORT void clear();
200
202 DLLLOCAL static const char *getStaticTypeName() {
203 return "binary";
204 }
205
207 DLLLOCAL static qore_type_t getStaticTypeCode() {
208 return NT_BINARY;
209 }
210 };
211
212 typedef SimpleRefHolder<BinaryNode> BinaryNodeHolder;
213
214 #endif // _QORE_BINARYNODE_H
NT_BINARY
const qore_type_t NT_BINARY
type value for BinaryNode
Definition: node_types.h:41
BinaryNode::compare
DLLEXPORT int compare(const BinaryNode *obj) const
returns 0 = equal, 1 = not equal
BinaryNode::is_equal_hard
virtual DLLEXPORT bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality
BinaryNode::size
DLLEXPORT qore_size_t size() const
returns the number of bytes in the object
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
BinaryNode::prepend
DLLEXPORT void prepend(const void *nptr, qore_size_t size)
resizes the object and prepends a copy of the data passed to the beginning of the object ...
qore_size_t
size_t qore_size_t
used for sizes (same range as a pointer)
Definition: common.h:62
qore_offset_t
long qore_offset_t
used for offsets that could be negative
Definition: common.h:65
BinaryNode::is_equal_soft
virtual DLLEXPORT bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const
tests for equality
BinaryNode::realCopy
virtual DLLEXPORT class AbstractQoreNode * realCopy() const
returns a copy of the object; the caller owns the reference count
BinaryNode::preallocate
DLLEXPORT int preallocate(qore_size_t size)
pre-allocates a buffer of a certain size
qore_type_t
signed short qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode) ...
Definition: common.h:59
QoreString
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:42
BinaryNode::splice
DLLEXPORT void splice(qore_offset_t offset, qore_offset_t length, BinaryNode *extract=0)
removes "length" characters from the binary data starting at position "offset"
BinaryNode::setSize
DLLEXPORT int setSize(qore_size_t size)
sets the buffer size after preallocation
BinaryNode::~BinaryNode
virtual DLLEXPORT ~BinaryNode()
frees and memory owned by the object
BinaryNode::parseInit
virtual DLLLOCAL AbstractQoreNode * parseInit(LocalVar *oflag, int pflag, int &lvids, const QoreTypeInfo *&typeInfo)
returns the type information
BinaryNode::empty
DLLEXPORT bool empty() const
returns true if empty
BinaryNode::clear
DLLEXPORT void clear()
frees any managed memory and sets the size to 0
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:35
SimpleRefHolder
manages a reference count of a pointer to a class that takes a simple "deref()" call with no argument...
Definition: ReferenceHolder.h:103
BinaryNode::substr
DLLEXPORT int substr(BinaryNode &b, qore_offset_t offset) const
copies data to the BinaryNode argument starting with byte position "offset"
BinaryNode::giveBuffer
DLLEXPORT void * giveBuffer()
returns the data being managed and leaves this object empty
BinaryNode::getTypeName
virtual DLLEXPORT const char * getTypeName() const
returns the type name as a c string
BinaryNode::getStaticTypeName
static DLLLOCAL const char * getStaticTypeName()
returns the type name (useful in templates)
Definition: BinaryNode.h:202
BinaryNode::getStaticTypeCode
static DLLLOCAL qore_type_t getStaticTypeCode()
returns the type code (useful in templates)
Definition: BinaryNode.h:207
SimpleValueQoreNode
base class for simple value types
Definition: AbstractQoreNode.h:417
BinaryNode::getAsBoolImpl
virtual DLLEXPORT bool getAsBoolImpl() const
returns false unless perl-boolean-evaluation is enabled, in which case it returns false only when emp...
BinaryNode::copy
DLLEXPORT BinaryNode * copy() const
returns a copy of the object
BinaryNode::getAsString
virtual DLLEXPORT int getAsString(QoreString &str, int foff, class ExceptionSink *xsink) const
concatenate the verbose string representation of the value to an existing QoreString ...
BinaryNode::getPtr
DLLEXPORT const void * getPtr() const
returns the pointer to the data
BinaryNode::append
DLLEXPORT void append(const void *nptr, qore_size_t size)
resizes the object and appends a copy of the data passed to the object
BinaryNode
holds arbitrary binary data
Definition: BinaryNode.h:33