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 declaration of classes and its members related to
28 #ifndef OC_HEADEROPTION_H_
29 #define OC_HEADEROPTION_H_
31 #include <OCException.h>
32 #include <StringConstants.h>
35 namespace HeaderOption
38 * @brief OCHeaderOption class allows to create instances which comprises optionID
39 * and optionData as members. These are used in setting Header options.
40 * After creating instances of OCHeaderOptions, use setHeaderOptions API
41 * (in OCResource.h) to set header Options.
42 * NOTE: HeaderOptionID is an unsigned integer value which MUST be within
43 * range of 2048 to 3000 inclusive of lower and upper bound
44 * except for If-Match with empty(num : 1), If-None-Match(num : 5),
45 * Location-Path(num : 8), Location-Query(num : 20) option.
46 * HeaderOptions instance creation fails if above condition is not satisfied.
48 const uint16_t MIN_HEADER_OPTIONID = 2048;
49 const uint16_t MAX_HEADER_OPTIONID = 3000;
50 const uint16_t IF_MATCH_OPTION_ID = 1;
51 const uint16_t IF_NONE_MATCH_OPTION_ID = 5;
52 const uint16_t LOCATION_PATH_OPTION_ID = 8;
53 const uint16_t LOCATION_QUERY_OPTION_ID = 20;
59 std::string m_optionData;
63 * OCHeaderOption constructor
65 OCHeaderOption(uint16_t optionID, std::string optionData):
67 m_optionData(optionData)
69 if (!(optionID >= MIN_HEADER_OPTIONID && optionID <= MAX_HEADER_OPTIONID)
70 && optionID != IF_MATCH_OPTION_ID
71 && optionID != IF_NONE_MATCH_OPTION_ID
72 && optionID != LOCATION_PATH_OPTION_ID
73 && optionID != LOCATION_QUERY_OPTION_ID)
75 throw OCException(OC::Exception::OPTION_ID_RANGE_INVALID);
79 virtual ~OCHeaderOption(){}
81 OCHeaderOption(const OCHeaderOption&) = default;
83 #if defined(_MSC_VER) && (_MSC_VER < 1900)
84 OCHeaderOption(OCHeaderOption&& o)
86 std::memmove(this, &o, sizeof(o));
89 OCHeaderOption(OCHeaderOption&&) = default;
92 OCHeaderOption& operator=(const OCHeaderOption&) = default;
94 #if defined(_MSC_VER) && (_MSC_VER < 1900)
95 OCHeaderOption& operator=(OCHeaderOption&& o)
97 std::memmove(this, &o, sizeof(o));
100 OCHeaderOption& operator=(OCHeaderOption&&) = default;
104 * API to get Option ID
105 * @return unsigned integer option ID
107 uint16_t getOptionID() const
113 * API to get Option data
114 * @return std::string of option data
116 std::string getOptionData() const
121 } // namespace HeaderOption
124 #endif // OC_HEADEROPTION_H_