Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
Serialize.hpp
Go to the documentation of this file.
1 //
2 // BEGIN_SOFTWARE_AND_SERVICES_COPYRIGHT
3 //
4 // Copyright (C) 2011-2014 Software and Services LLC, All Rights Reserved.
5 //
6 // NOTICE:
7 //
8 // THIS SOURCE CODE BELONGS TO Software and Services LLC.
9 // THIS CODE IS PROPERTY OF THE COPYRIGHT HOLDER AND IS NOT TO
10 // BE DIVULGED OR USED BY PARTIES WHO HAVE NOT RECEIVED WRITTEN
11 // AUTHORIZATION FROM THE OWNER.
12 //
13 // THIS SOFTWARE AND MANUAL ARE BOTH PROTECTED BY UNITED STATES
14 // COPYRIGHT LAW (TITLE 17 UNITED STATES CODE). UNAUTHORIZED REPRODUCTION
15 // AND/OR SALE MAY RESULT IN IMPRISONMENT OF UP TO ONE YEAR AND FINES
16 // OF UP TO $100,000 (17 USC 506). COPYRIGHT INFRINGERS MAY ALSO
17 // BE SUBJECT TO CIVIL LIABILITY.
18 //
19 // THIS NOTICE AND THE ABOVE COPYRIGHT NOTICE MUST REMAIN IN ALL
20 // COPIES AND ANY DERIVED WORK.
21 //
22 // ALL OF THIS CODE IS ORIGINAL WORK BY THE COPYRIGHT HOLDER.
23 //
24 // THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN IS
25 // PROVIDED ON AN "AS IS" BASIS AND Software and Services LLC.
26 // DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
27 // NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
28 // HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
29 // WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
30 // PURPOSE.
31 //
32 // END_SOFTWARE_AND_SERVICES_COPYRIGHT
33 //
34 
44 #ifndef SOFTWARE_AND_SERVICES_LIBRARY_COMMON_SERIALIZE_HPP_
45 #define SOFTWARE_AND_SERVICES_LIBRARY_COMMON_SERIALIZE_HPP_
46 
47 #ifdef WIN32
48 #pragma warning (disable : 4251)
49 #endif
50 
51 #ifdef BUILDING_SAS_COMMON_LIBRARY
52 #include "osver.h"
53 #include "File.hpp"
54 #include "VBase.hpp"
55 #include "winWrappers.hpp"
56 #else
57 #include <SaS/Common/osver.h>
58 #include <SaS/Common/File.hpp>
59 #include <SaS/Common/VBase.hpp>
60 #include <SaS/Common/winWrappers.hpp>
61 #endif
62 
63 #include <vector>
64 
65 #ifndef EXPORT_COMMON
66 #ifdef BUILDING_SAS_COMMON_LIBRARY
67 #define EXPORT_COMMON EXPORT_OUT
68 #else
69 #define EXPORT_COMMON EXPORT_IN
70 #endif
71 #endif
72 
74 
75 namespace SoftwareAndServices
76 {
77  namespace Library
78  {
79  namespace Common
80  {
86  class EXPORT_COMMON Serialize
87  : virtual public VBase,
88  virtual public instance<Serialize>
89  {
90 
91  public:
92 
96  Serialize();
97 
103  Serialize(File * IoPath);
104 
108  virtual ~Serialize();
109 
116  void operator delete(void * data);
117 
121  typedef unsigned long long SerializeSize_t;
122 
134  virtual SerializeSize_t
135  SerialRead(void * PutHere,
136  SerializeSize_t OctetsToRead) = 0;
137 
149  virtual SerializeSize_t
150  SerialWrite(void * GetHere,
151  SerializeSize_t OctetsToWrite) = 0;
152 
166  void Asynchronous(bool On);
167 
171  bool Asynchronous() const;
172 
183  SerializeSize_t ReadCount() const;
184 
195  SerializeSize_t WriteCount() const;
196 
197  private:
198 
202  File * _IoPath;
203 
208  bool _InAsyncMode;
209 
214  struct SaSIoRecord {
215 
219  SaSIoRecord();
220 
224  virtual ~SaSIoRecord();
225 
229  File * _FileObject;
230 
234  void * _Data;
235 
239  SerializeSize_t _DataSize;
240  };
241 
245  std::vector<SaSIoRecord*> _ReadQueue;
246 
250  std::vector<SaSIoRecord*> _WiteQueue;
251 
252  };
253  }
254  }
255 }
256 
257 #endif // SOFTWARE_AND_SERVICES_LIBRARY_COMMON_SERIALIZE_HPP_
Like &#39;FILE&#39;, except C++ implementation and allows sockets and disk files to use same object on WINDOW...
Definition: File.hpp:150
"<SaS/Common/winWrappers.hpp>" Various definitions needed when compiling on Microsoft Windows...
Generic buffered IO.
unsigned long long SerializeSize_t
Used like size_t for octet counting.
Definition: Serialize.hpp:121
Instance counting and tracking.
Definition: instance.hpp:90
Copyright Douglas Mark Royer DouglasRoyer@gmail.com.
Definition: Base.hpp:98
Base virtual functions for IO.
This is a pure abstract base class and it is used for serializing objects.
Definition: Serialize.hpp:86
"<SaS/Common/psver.h>" Definitions specific to various OS&#39;s and OS versions.
A pure virtual Base class for reading and writing object.
Definition: VBase.hpp:81