Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
SQLENUM.hpp
1 
5 //
6 // (C) Copyright 2001-2016 Douglas Mark Royer, All Rights Reserved.
7 //
8 // NOTICE:
9 //
10 // THIS SOURCE CODE BELONGS TO DOUGLAS MARK ROYER. THIS CODE IS CONSIDERED A
11 // TRADE SECRET AND IS NOT TO BE DIVULGED OR USED BY PARTIES WHO HAVE
12 // NOT RECEIVED WRITTEN AUTHORIZATION FROM THE OWNER.
13 //
14 // THIS SOURCE CODE IS UNPUBLISHED WORK FULLY PROTECTED BY THE UNITED
15 // STATES COPYRIGHT LAWS AND IS CONSIDERED A TRADE SECRET BELONGING
16 // TO THE COPYRIGHT HOLDER.
17 //
18 // THIS SOFTWARE AND MANUAL ARE BOTH PROTECTED BY UNITED STATES
19 // COPYRIGHT LAW (TITLE 17 UNITED STATES CODE). UNAUTHORIZED REPRODUCTION
20 // AND/OR SALE MAY RESULT IN IMPRISONMENT OF UP TO ONE YEAR AND FINES
21 // OF UP TO $100,000 (17 USC 506). COPYRIGHT INFRINGERS MAY ALSO
22 // BE SUBJECT TO CIVIL LIABILITY.
23 //
24 // ALL OF THIS CODE IS ORIGINAL WORK BY THE COPYRIGHT HOLDER.
25 //
26 
27 #ifndef _DOUGLAS_MARK_ROYER_SQL_TOOLS_SQLENUM_HPP
28 #define _DOUGLAS_MARK_ROYER_SQL_TOOLS_SQLENUM_HPP
29 
30 #ifdef BUILDING_LIBRARY_SQL
31 #include "Types.hpp"
32 #else
33 #include <SaS/Sql/Types.hpp>
34 #endif
35 
36 namespace SoftwareAndServices
37 {
38  namespace Library
39  {
40  namespace Database
41  {
42 
47  class SQLENUM
48  : public SqlColumn
49  {
50 
51  public:
52 
56  SQLENUM();
57 
63  SQLENUM(const char * Val);
64 
70  SQLENUM(const SQLENUM & CopyFrom);
71 
75  virtual ~SQLENUM();
76 
82  void Name(const char * TheName);
83 
87  const char * Name() const;
88 
94  const char * TypeName() const;
95 
99  virtual const char * toString() const;
100 
106  virtual bool fromString(const char * TheValue);
107 
116  static SQLENUM * FindEnum(const char * ToFind);
117 
126  static SQLENUM * FindEnum(const String & ToFind);
127 
136  static SQLENUM * FindEnum(const std::string & ToFind);
137 
138 #ifdef USE_QT5
139 
147  static SQLENUM * FindEnum(const QString & ToFind);
148 #endif
149 
155  void Add(const char * ValToAdd);
156 
162  void Add(const String & ValToAdd);
163 
169  void Add(const std::string & ValToAdd);
170 
171 #ifdef USE_QT5
172 
177  void Add(const QString & ValToAdd);
178 #endif
179 
183  std::vector<const char*> * Values() const;
184 
193  bool Check(const char * ToCheck) const;
194 
203  bool Check(const String & ToCheck) const;
204 
213  bool Check(const std::string & ToCheck) const;
214 
215 #ifdef USE_QT5
216 
224  bool Check(const QString & ToCheck) const;
225 #endif
226 
232  virtual DataTypeBase * Copy() const;
233 
239  static const std::map<const char*, SQLENUM*> * AllEnums();
240 
245  virtual const char * BaseType() const;
246 
265  static void ToVector(const char * OneString,
266  std::vector<SQLENUM*> & Results);
267 
277  static void FromVector(std::vector<SQLENUM*> & Vector,
278  String & Results);
279 
280  private:
281 
287  class SqlEnumValues
288  : public instance<SqlEnumValues>
289  {
290 
291  public:
292 
296  SqlEnumValues();
297 
303  SqlEnumValues(const SqlEnumValues & CopyFrom);
304 
308  virtual ~SqlEnumValues();
309 
313  const char * Name;
314 
318  std::vector<const char*> * Values;
319 
327  SqlEnumValues * Copy() const;
328 
329  private:
330 
335  bool _Printed;
336  };
337 
343  const char * _Value;
344 
348  SqlEnumValues * _Type;
349 
353  static std::map<const char*, SQLENUM*> * _AllEnums;
354 
355  };
356  }
357  }
358 }
359 #endif //_DOUGLAS_MARK_ROYER_SQL_TOOLS_SQLENUM_HPP
static const std::map< const char *, SQLENUM * > * AllEnums()
Get a list of all enums.
static void ToVector(const char *OneString, std::vector< SQLENUM *> &Results)
Convert an SQL array result to an array of SqlColumn values.
virtual const char * toString() const
Convert the object value to a string.
virtual const char * BaseType() const
Get the C++ base type name.
std::vector< const char * > * Values() const
Get the list of values.
static void FromVector(std::vector< SQLENUM *> &Vector, String &Results)
Convert an array of values, into a form suitable for an insert.
A base object for DataType objects.
Definition: SQL.hpp:1800
Copyright Douglas Mark Royer DouglasRoyer@gmail.com.
Definition: Base.hpp:98
bool Check(const char *ToCheck) const
Check to see if a value is valid.
virtual DataTypeBase * Copy() const
Copy this object.
void Add(const char *ValToAdd)
Add a new value to this ENUM.
const char * TypeName() const
Get the type name.
virtual ~SQLENUM()
SQLENUM - Destructor.
An object that represents a enum.
Definition: SQLENUM.hpp:47
virtual bool fromString(const char *TheValue)
Convert the object value from a string.
static SQLENUM * FindEnum(const char *ToFind)
Find the named ENUM.
SQLENUM()
SQLENUM - Default Constructor.