Remote Call Framework 3.3
DataPtr.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2022, Delta V Software. All rights reserved.
6 // https://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF under GPL terms.
12 //
13 // Version: 3.3
14 // Contact: support <at> deltavsoft.com
15 //
16 //******************************************************************************
17 
18 #ifndef INCLUDE_SF_DATAPTR_HPP
19 #define INCLUDE_SF_DATAPTR_HPP
20 
21 #include <string>
22 
23 #include <RCF/Export.hpp>
24 
25 #include <SF/PortableTypes.hpp>
26 
27 namespace SF {
28 
29  //************************************************************************
30  // DataPtr class holds a pointer to a buffer of data. It includes an internal
31  // buffer in order to avoid dynamic memory allocation for small buffer sizes, < 64bytes.
32 
33  class RCF_EXPORT DataPtr
34  {
35  private:
36  typedef Byte8 T;
37  public:
38  DataPtr();
39  DataPtr(const T *sz);
40  DataPtr(const T *sz, UInt32 length);
41  DataPtr(const DataPtr &rhs);
42  DataPtr &operator=(const DataPtr &rhs);
43  ~DataPtr();
44 
45  void assign(const T *sz, UInt32 length);
46  void assign(const T *sz);
47  void assign(const std::string &s);
48 
49  void release();
50  UInt32 allocate(UInt32 length);
51  T *get() const;
52  UInt32 length() const;
53  bool empty() const;
54  std::string cpp_str() const;
55 
56  private:
57  T *ptr_;
58  UInt32 length_;
59  UInt32 allocatedLength_;
60  int whichDeleter_;
61  void (*pfn_deleter_)(T *);
62  T buffer_[64];
63  UInt32 length(const T *sz);
64  };
65 
66 } // namespace SF
67 
68 #endif // ! INCLUDE_SF_DATAPTR_HPP
Definition: ByteBuffer.hpp:188