summaryrefslogtreecommitdiffstats
path: root/tags/cpp-1.0-incubating-M2-final/sdo/runtime/core/src/commonj/sdo/Setting.h
blob: 19980d7b041b47aee23d1167a332d039a8e5d225 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

/* $Rev$ $Date$ */

#ifndef SETTING_H
#define SETTING_H

#include "commonj/sdo/export.h"

#include "commonj/sdo/Type.h"
#include "commonj/sdo/DataObject.h"
#include "commonj/sdo/SDODate.h"

namespace commonj{
namespace sdo {

    class Property;

     /**  
     * A Setting encapsulates a property and a corresponding single value of 
     * the property's type.
      */

    class Setting
    {
          public:

        Setting(bool set, bool nul, void* invalue, unsigned int len, const Property& p, 
            unsigned int inindex);

        Setting(const Setting& s);

        void copy(const Setting& s);

        Setting& operator=(const Setting& s);


        virtual ~Setting();


         /**  getProperty returns the property set.
         *
         * Returns the property of the Setting.
         * @return the Setting property.
          */
        
        SDO_API const Property& getProperty() const;

        /**  getType returns the type of the property
         *
         * Returns the type of this property. This is the same as
         * getProperty().getType()
          */
        
        SDO_API const Type& getType() const;

        /**  getTypeEnum returns the type enumerator
         *
         * Returns the enum for the type of this property
          */

        SDO_API Type::Types getTypeEnum() const;


         /** get methods get the right type of value from the setting
         *
         *
         * Returns the value of the Setting. This must be of the right type for 
         * Setting value.
          */
        
        SDO_API bool getBooleanValue() const;
        SDO_API char getByteValue() const;
        SDO_API wchar_t getCharacterValue() const;
        SDO_API unsigned int getBytesValue(char* buffer, unsigned int max) const;
        SDO_API unsigned int getStringValue(wchar_t* buffer, unsigned int max) const;
        SDO_API short getShortValue() const;
        SDO_API long getIntegerValue() const;
        SDO_API int64_t getLongValue() const;
        SDO_API float getFloatValue() const;
        SDO_API long double getDoubleValue() const;
        SDO_API const SDODate getDateValue() const;
        SDO_API const char* getCStringValue() ;
        SDO_API DataObjectPtr getDataObjectValue() const;



         /**  getIndex returns the index in a many-valued property
         *
         * Returns the index  of the Setting, if this is many valued
          */

        SDO_API unsigned int getIndex() const; 


        /**  getLength gives the length of a string or bytes
         *
         * Returns the length of the setting, if this is a String or
         * Bytes type
         */

        SDO_API unsigned int getLength() const ; 
        
        /** isSet returns whether the property WAS set.
         *
         * Returns whether or not the property is set. This value comes from the
         * setting, and tells us whether the property was set before the change
         * occurred.
          */

        SDO_API bool isSet() const;

        /**  isNull is true if the property value WAS null
         *
         * Returns whether or not the property was null beforfe the setting
         * happened.
          */

        SDO_API bool isNull() const;

        private:

            bool bisSet;
            bool bisNull;
            void* value;
            const Property* theProp;
            unsigned int length;
            unsigned int index;
            char* strbuf;
    };
};
};

#endif