1 martin 1.22 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.23 //
|
3 martin 1.22 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.23 //
|
10 martin 1.22 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.23 //
|
17 martin 1.22 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.23 //
|
20 martin 1.22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.23 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.23 //
|
28 martin 1.22 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.8 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32
33 //
34 // Header for a class to generate CIMValue objects from String values
35 //
36
37 #ifndef _VALUEFACTORY_H_
38 #define _VALUEFACTORY_H_
39
40 #include <Pegasus/Common/String.h>
41 #include <Pegasus/Common/CIMValue.h>
|
42 kumpf 1.13 #include <Pegasus/Compiler/Linkage.h>
|
43 mike 1.8
44 PEGASUS_USING_PEGASUS;
45 PEGASUS_USING_STD;
46
47 // The valueFactory builds a CIMValue object given an indication of
48 // whether this is a Array type, the CIM type to be coerced, and
49 // a String representation of the value.
50 //
|
51 karl 1.19 class PEGASUS_COMPILER_LINKAGE valueFactory
52 {
|
53 kumpf 1.21 public:
|
54 karl 1.23.8.2 /**
55 Escape any character comma found in the input string
56 @param str String to be processed.
57 @return String the processed string
58 */
59 static String stringEscapeComma(String str);
|
60 kumpf 1.21
61 /**
62 Converts a String to a Uint64 according to the DMTF specification for
63 MOF encoding. A CIMType specification also allows for overflow
64 checking of smaller unsigned integer type (e.g., Uint8, Uint16,
65 Uint32).
66 @param val The String to convert
67 @param type A CIMType to use for bounds checking
68 @exception Exception if the conversion is unsuccessful
69 @return The converted Uint64 value
70 */
71 static Uint64 stringToUint(
72 const String& val,
73 CIMType type);
74
75 /**
76 Converts a String to a Sint64 according to the DMTF specification for
77 MOF encoding. A CIMType specification also allows for overflow
78 checking of smaller unsigned integer type (e.g., Sint8, Sint16,
79 Sint32).
80 @param val The String to convert
81 kumpf 1.21 @param type A CIMType to use for bounds checking
82 @exception Exception if the conversion is unsuccessful
83 @return The converted Sint64 value
84 */
85 static Sint64 stringToSint(
86 const String& val,
87 CIMType type);
88
89 /**
90 Converts a String to a Rint64 according to the DMTF specification for
91 MOF encoding.
92 @param val The String to convert
93 @param type A CIMType to use in an exception message
94 @exception Exception if the conversion is unsuccessful
95 @return The converted Real64 value
96 */
97 static Real64 stringToReal(
98 const String& val,
99 CIMType type);
100
101 static CIMValue * createValue(CIMType type, int arrayDimension,
102 kumpf 1.21 Boolean isNull,
|
103 karl 1.23.8.2 int ParseType,
|
104 kumpf 1.21 const String *rep);
105
106 private:
107
108 static CIMValue* _buildArrayValue(
109 CIMType type,
110 const String& rep);
|
111 karl 1.23.8.2
112 static Boolean compareTypeToParseType(CIMType type, int expectedType );
|
113 mike 1.8 };
114
115 #endif
|