1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This file contains the definition of the internally used type
28 #ifndef __ATTRIBUTEVALUE_H
29 #define __ATTRIBUTEVALUE_H
31 // These defines are required to get the boost::variant to hold more than 20 items.
32 // documentation requires that you use a power of 10
33 #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
34 #define BOOST_MPL_LIMIT_LIST_SIZE 30
35 #define BOOST_MPL_LIMIT_VECTOR_SIZE 30
36 #include <boost/variant.hpp>
38 #include <OCUtilities.h>
41 class OCRepresentation;
45 // Since null needs to be encoded in a special fashion in JSON, the encoder
46 // needs to know the index of the NullType Sentinel Any time the code does a special
47 // case for the NullType, we use the AttributeValueNullIndex. This MUST be kept up to date
48 // with the variant's which() for NullType.
49 static const int AttributeValueNullIndex = 0;
50 typedef boost::variant<
51 NullType, // Note: this handles the null-type and must match the above static const
62 std::vector<std::string>,
63 std::vector<OC::OCRepresentation>,
66 std::vector<std::vector<int>>,
67 std::vector<std::vector<std::vector<int>>>,
69 std::vector<std::vector<double>>,
70 std::vector<std::vector<std::vector<double>>>,
72 std::vector<std::vector<bool>>,
73 std::vector<std::vector<std::vector<bool>>>,
75 std::vector<std::vector<std::string>>,
76 std::vector<std::vector<std::vector<std::string>>>,
78 std::vector<std::vector<OC::OCRepresentation>>,
79 std::vector<std::vector<std::vector<OC::OCRepresentation>>>
82 enum class AttributeType
94 struct AttributeTypeConvert{};
97 struct AttributeTypeConvert<NullType>
99 constexpr static AttributeType type = AttributeType::Null;
103 struct AttributeTypeConvert<int>
105 constexpr static AttributeType type = AttributeType::Integer;
109 struct AttributeTypeConvert<double>
111 constexpr static AttributeType type = AttributeType::Double;
115 struct AttributeTypeConvert<bool>
117 constexpr static AttributeType type = AttributeType::Boolean;
121 struct AttributeTypeConvert<std::string>
123 constexpr static AttributeType type = AttributeType::String;
127 struct AttributeTypeConvert<OCRepresentation>
129 constexpr static AttributeType type = AttributeType::OCRepresentation;
132 std::ostream& operator << (std::ostream& os, const AttributeType at);
134 #endif // __ATTRIBUTEVALUE_H