KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
EnumDescriptor.h
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 For Further Information Please Contact me at
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
29 
30 /********************************************************************
31  EnumDescriptor
32  created: 20/07/2010
33  author: Karl Jones
34 
35  purpose: Structure for holding a string to associate with an enum value.
36  This allows for converting enumerations into their string representations.
37 *********************************************************************/
38 
39 #pragma once
40 
41 #include "./../../KDefines.h"
42 
43 namespace KDIS {
44 namespace DATA_TYPE {
45 namespace ENUMS {
46 
48 {
49 public:
50  const KINT32 Value;
51  const KCHAR8 * Name;
52 };
53 
54 //************************************
55 // FullName: KDIS::DATA_TYPE::ENUMS::GetEnumAsString
56 //!Description: Uses a binary search to find the enum element.
57 // Parameter: const EnumDescriptor * pArray
58 // Parameter: KUINT32 NumElements
59 // Parameter: KINT32 Value
60 //************************************
61 KDIS_EXPORT KString GetEnumAsString( const EnumDescriptor * pArray, KUINT32 NumElements, KINT32 Value );
62 
63 //************************************
64 // FullName: KDIS::DATA_TYPE::ENUMS::GetEnumFromString
65 //!Description: Uses a linear search to find the enum value from a string. Search is case sensitive..
66 // Returns true if a match was found else false.
67 // Parameter: const EnumDescriptor * pArray
68 // Parameter: KUINT32 NumElements
69 // Parameter: const KString & Value
70 // Parameter: KINT32 & ValueOut - The returned value if search found one.
71 //************************************
72 KDIS_EXPORT KBOOL GetEnumFromString( const EnumDescriptor * pArray, KUINT32 NumElements, const KString & Value, KINT32 & ValueOut );
73 
74 } // END namespace ENUMS
75 } // END namespace DATA_TYPES
76 } // END namespace KDIS
unsigned int KUINT32
Definition: KDefines.h:103
char KCHAR8
Definition: KDefines.h:110
KString GetEnumAsString(const EnumDescriptor *pArray, KUINT32 NumElements, KINT32 Value)
Description: Uses a binary search to find the enum element.
int KINT32
Definition: KDefines.h:104
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
Definition: EnumDescriptor.h:47
#define KDIS_EXPORT
Definition: KDefines.h:82
KBOOL GetEnumFromString(const EnumDescriptor *pArray, KUINT32 NumElements, const KString &Value, KINT32 &ValueOut)
Description: Uses a linear search to find the enum value from a string. Search is case sensitive...
const KINT32 Value
Definition: EnumDescriptor.h:50
const KCHAR8 * Name
Definition: EnumDescriptor.h:51