2 //******************************************************************
4 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
6 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
12 // http://www.apache.org/licenses/LICENSE-2.0
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
20 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 /// @file AttributeValue.h
24 /// @brief This file contains the definition of the internally used
25 // type AttributeValue
27 #ifndef __ATTRIBUTEVALUE_H
28 #define __ATTRIBUTEVALUE_H
30 // These defines are required to get the boost::variant to hold more than 20 items.
31 // documentation requires that you use a power of 10
32 #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
33 #define BOOST_MPL_LIMIT_LIST_SIZE 30
34 #define BOOST_MPL_LIMIT_VECTOR_SIZE 30
35 #include <boost/variant.hpp>
37 #include <OCUtilities.h>
40 class OCRepresentation;
44 // Since null needs to be encoded in a special fashion in JSON, the encoder
45 // needs to know the index of the NullType Sentinel Any time the code does a special
46 // case for the NullType, we use the AttributeValueNullIndex. This MUST be kept up to date
47 // with the variant's which() for NullType.
48 static const int AttributeValueNullIndex = 0;
49 typedef boost::variant<
50 NullType, // Note: this handles the null-type and must match the above static const
61 std::vector<std::string>,
62 std::vector<OC::OCRepresentation>,
65 std::vector<std::vector<int>>,
66 std::vector<std::vector<std::vector<int>>>,
68 std::vector<std::vector<double>>,
69 std::vector<std::vector<std::vector<double>>>,
71 std::vector<std::vector<bool>>,
72 std::vector<std::vector<std::vector<bool>>>,
74 std::vector<std::vector<std::string>>,
75 std::vector<std::vector<std::vector<std::string>>>,
77 std::vector<std::vector<OC::OCRepresentation>>,
78 std::vector<std::vector<std::vector<OC::OCRepresentation>>>
81 enum class AttributeType
93 struct AttributeTypeConvert{};
96 struct AttributeTypeConvert<NullType>
98 constexpr static AttributeType type = AttributeType::Null;
102 struct AttributeTypeConvert<int>
104 constexpr static AttributeType type = AttributeType::Integer;
108 struct AttributeTypeConvert<double>
110 constexpr static AttributeType type = AttributeType::Double;
114 struct AttributeTypeConvert<bool>
116 constexpr static AttributeType type = AttributeType::Boolean;
120 struct AttributeTypeConvert<std::string>
122 constexpr static AttributeType type = AttributeType::String;
126 struct AttributeTypeConvert<OCRepresentation>
128 constexpr static AttributeType type = AttributeType::OCRepresentation;
131 std::ostream& operator << (std::ostream& os, const AttributeType at);
133 #endif // __ATTRIBUTEVALUE_H