Fledge
An open source edge computing platform for industrial users
omfbuffer.h
1 #ifndef _OMF_BUFFER_H
2 #define _OMF_BUFFER_H
3 /*
4  * Fledge OMF North plugin buffer class
5  *
6  * Copyright (c) 2023 Dianomic Systems
7  *
8  * Released under the Apache 2.0 Licence
9  *
10  * Author: Mark Riddoch
11  */
12 
13 #include <string>
14 #include <list>
15 
16 #define BUFFER_CHUNK 8192
17 
24 class OMFBuffer {
25  class Buffer {
26  public:
27  Buffer();
28  Buffer(unsigned int);
29  ~Buffer();
30  char *detach();
31  char *data;
32  unsigned int offset;
33  unsigned int length;
34  bool attached;
35  };
36 
37  public:
38  OMFBuffer();
39  ~OMFBuffer();
40 
41  bool isEmpty() { return buffers.empty() || (buffers.size() == 1 && buffers.front()->offset == 0); }
42  void append(const char);
43  void append(const char *);
44  void append(const int);
45  void append(const unsigned int);
46  void append(const long);
47  void append(const unsigned long);
48  void append(const double);
49  void append(const std::string&);
50  void quote(const std::string&);
51  const char *coalesce();
52  void clear();
53 
54  private:
55  std::list<Buffer *> buffers;
56 };
57 
58 #endif
void append(const char)
Append a character to a buffer.
Definition: omfbuffer.cpp:57
OMFBuffer()
Buffer class designed to hold OMF payloads that can as required but have minimal copy semantics...
Definition: omfbuffer.cpp:23
void quote(const std::string &)
Quote and append a string to a buffer.
Definition: omfbuffer.cpp:241
const char * coalesce()
Create a coalesced buffer from the buffer chain.
Definition: omfbuffer.cpp:275
void clear()
Clear all the buffers from the OMFBuffer and allow it to be reused.
Definition: omfbuffer.cpp:42
Buffer class designed to hold OMF payloads that can grow as required but have minimal copy semantics...
Definition: omfbuffer.h:24
~OMFBuffer()
OMFBuffer destructor.
Definition: omfbuffer.cpp:31