1 /******************************************************************
\r
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
19 ******************************************************************/
\r
22 * @file AllowedValues.h
\r
24 * @brief This file provides data Model for Json Schema AllowedValues.
\r
27 #ifndef ALLOWED_VALUES_H_
\r
28 #define ALLOWED_VALUES_H_
\r
33 #include <boost/variant.hpp>
\r
34 #include <boost/lexical_cast.hpp>
\r
35 #include "Helpers.h"
\r
40 * @class AllowedValues
\r
41 * @brief This class provides data Model for Json Schema AllowedValues.
\r
47 * This method is for setting AllowedValues
\r
49 * @param value - Allowed Value to set.
\r
51 template <typename T>
\r
52 void addValue(const T &value)
\r
54 ValueVariant temp = value;
\r
55 m_values.push_back(temp);
\r
59 * This method is for setting AllowedValues
\r
61 * @param values - list of Allowed Values to set.
\r
63 template <typename T>
\r
64 void addValues(const std::vector<T> &values)
\r
66 for (auto value : values)
\r
68 ValueVariant vValue = value;
\r
69 m_values.push_back(vValue);
\r
74 * This method is for getting AllowedValues
\r
76 * @param index - Allowed Values at index to be fetched
\r
78 inline ValueVariant &at(int index)
\r
80 return m_values.at(index);
\r
84 * This method is for getting size of AllowedValues
\r
86 * @return size of Allowed Values list
\r
88 inline int size() const
\r
90 return m_values.size();
\r
94 * This method is for getting AllowedValues.
\r
96 * @return list of AllowedValues
\r
98 inline std::vector<ValueVariant> getValues()
\r
104 * This method is for getting AllowedValues as integer.
\r
106 * @return list of AllowedValues as integer.
\r
108 inline std::vector<int> getValuesInt()
\r
110 std::vector<int> values;
\r
111 for (auto value : m_values)
\r
113 values.push_back(boost::lexical_cast<int> (value));
\r
119 * This method is for getting AllowedValues as string.
\r
121 * @return list of AllowedValues as string.
\r
123 inline std::vector<std::string> getValuesString()
\r
125 std::vector<std::string> values;
\r
126 for (auto value : m_values)
\r
128 values.push_back(boost::lexical_cast<std::string> (value));
\r
134 * This method is for getting AllowedValues as Double.
\r
136 * @return list of AllowedValues as Double.
\r
138 inline std::vector<double> getValuesDouble()
\r
140 std::vector<double> values;
\r
141 for (auto value : m_values)
\r
143 values.push_back(boost::lexical_cast<double> (value));
\r
149 * This method is for getting AllowedValues as Bool.
\r
151 * @return list of AllowedValues as Bool.
\r
153 inline std::vector<bool> getValuesBool()
\r
155 std::vector<bool> values;
\r
156 for (auto value : m_values)
\r
158 values.push_back(boost::lexical_cast<bool> (value));
\r
164 std::vector<ValueVariant> m_values;
\r