Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
Guid.hpp
Go to the documentation of this file.
1 //
2 // BEGIN_SOFTWARE_AND_SERVICES_COPYRIGHT
3 //
4 // Copyright (C) 2016 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 
39 #ifndef SOFTWARE_AND_SERVICES_LIBRARY_COMMON_GUID_HPP_
40 #define SOFTWARE_AND_SERVICES_LIBRARY_COMMON_GUID_HPP_
41 
42 #ifdef WIN32
43 #pragma warning (disable : 4251)
44 #endif
45 
46 #ifdef BUILDING_SAS_COMMON_LIBRARY
47 #include "osver.h"
48 #include "winWrappers.hpp"
49 #include "instance.hpp"
50 #include "String.hpp"
51 #include "StringCache.hpp"
53 #else
54 #include <SaS/Common/osver.h>
55 #include <SaS/Common/winWrappers.hpp>
56 #include <SaS/Common/instance.hpp>
57 #include <SaS/Common/String.hpp>
58 #include <SaS/Common/StringCache.hpp>
59 #include <SaS/Common/StringCompareOperator.hpp>
60 #endif
61 
62 #ifndef EXPORT_COMMON
63 #ifdef BUILDING_SAS_COMMON_LIBRARY
64 #define EXPORT_COMMON EXPORT_OUT
65 #else
66 #define EXPORT_COMMON EXPORT_IN
67 #endif
68 #endif
69 
70 #include <map>
71 
72 namespace SoftwareAndServices
73 {
74  namespace Library
75  {
76  namespace Common
77  {
78 
83  class EXPORT_COMMON GUID
84  : virtual public instance<String>
85  {
86 
87  public:
88 
92  GUID();
93 
97  virtual ~GUID();
98 
106  void Set(const char * App,
107  const char * GuidValue);
108 
115  static const char * Generate();
116 
128  bool Get(String & App, String & GuidValue) const;
129 
138  static GUID * LookupByGUID(const char * GuidValue);
139 
148  static GUID * LookupByApp(const char * App);
149 
157  GUID & operator=(const GUID & CopyFrom);
158 
162  operator const char *() const;
163 
171  bool operator==(const GUID & Other) const;
172 
180  bool operator!=(const GUID & Other) const;
181 
192  static bool Load();
193 
203  static bool Save();
204 
205  private:
206 
210  const char * _Guid;
211 
215  const char * _App;
216 
220  static std::map<const char*,GUID*,CStringCompareOperator>
221  * _ByGuid;
222 
226  static std::map<const char*,GUID*,CStringCompareOperator>
227  * _ByApp;
228 
232  static bool _NeedsSaved;
233 
237  void _AddIfNew();
238  };
239 
240  }
241  }
242 }
243 
244 extern "C"
245 {
255  bool_t xdr_GUID(XDR * xdrs, GUID * GuidPtr);
256 }
257 
258 #endif // SOFTWARE_AND_SERVICES_LIBRARY_COMMON_GUID_HPP_
Compares c-string (char*).
"<SaS/Common/winWrappers.hpp>" Various definitions needed when compiling on Microsoft Windows...
"<SaS/Common/StringCache.hpp>"Cache commonly used strings.
Registration of application and library identifiers.
Definition: Guid.hpp:83
bool_t xdr_GUID(XDR *xdrs, GUID *GuidPtr)
An XDR/RPC encode/decode method.
Instance counting and tracking.
Definition: instance.hpp:90
This is a class that allows:
Definition: String.hpp:114
Copyright Douglas Mark Royer DouglasRoyer@gmail.com.
Definition: Base.hpp:98
Base class for instance counting objects.
"<SaS/Common/psver.h>" Definitions specific to various OS&#39;s and OS versions.
"<SaS/Common/String.hpp>"String manipulation routines for C++