Lines Matching full:element
81 * Returns the specified property of the specified JSON element.
85 * @param element JSON element
92 inline const nlohmann::json& getRequiredProperty(const nlohmann::json& element, in getRequiredProperty() argument
95 auto it = element.find(property); in getRequiredProperty()
96 if (it == element.end()) in getRequiredProperty()
105 * Parses a JSON element containing a boolean.
111 * @param element JSON element
114 inline bool parseBoolean(const nlohmann::json& element) in parseBoolean() argument
116 // Verify element contains a boolean in parseBoolean()
117 if (!element.is_boolean()) in parseBoolean()
119 throw std::invalid_argument{"Element is not a boolean"}; in parseBoolean()
121 return element.get<bool>(); in parseBoolean()
125 * Parses a JSON element containing a GPIO.
131 * @param element JSON element
134 GPIO parseGPIO(const nlohmann::json& element);
137 * Parses a JSON element containing a rail.
143 * @param element JSON element
146 std::unique_ptr<Rail> parseRail(const nlohmann::json& element);
149 * Parses a JSON element containing an array of rails.
155 * @param element JSON element
159 const nlohmann::json& element);
162 * Parses the JSON root element of the entire configuration file.
168 * @param element JSON element
171 std::vector<std::unique_ptr<Rail>> parseRoot(const nlohmann::json& element);
174 * Parses a JSON element containing a string.
180 * @param element JSON element
184 inline std::string parseString(const nlohmann::json& element, in parseString() argument
187 if (!element.is_string()) in parseString()
189 throw std::invalid_argument{"Element is not a string"}; in parseString()
191 std::string value = element.get<std::string>(); in parseString()
194 throw std::invalid_argument{"Element contains an empty string"}; in parseString()
200 * Parses a JSON element containing an 8-bit unsigned integer.
206 * @param element JSON element
209 inline uint8_t parseUint8(const nlohmann::json& element) in parseUint8() argument
211 // Verify element contains an integer in parseUint8()
212 if (!element.is_number_integer()) in parseUint8()
214 throw std::invalid_argument{"Element is not an integer"}; in parseUint8()
216 int value = element.get<int>(); in parseUint8()
219 throw std::invalid_argument{"Element is not an 8-bit unsigned integer"}; in parseUint8()
225 * Parses a JSON element containing an unsigned integer.
231 * @param element JSON element
234 inline unsigned int parseUnsignedInteger(const nlohmann::json& element) in parseUnsignedInteger() argument
236 // Verify element contains an unsigned integer in parseUnsignedInteger()
237 if (!element.is_number_unsigned()) in parseUnsignedInteger()
239 throw std::invalid_argument{"Element is not an unsigned integer"}; in parseUnsignedInteger()
241 return element.get<unsigned int>(); in parseUnsignedInteger()
245 * Verifies that the specified JSON element is a JSON array.
247 * Throws an invalid_argument exception if the element is not an array.
249 * @param element JSON element
251 inline void verifyIsArray(const nlohmann::json& element) in verifyIsArray() argument
253 if (!element.is_array()) in verifyIsArray()
255 throw std::invalid_argument{"Element is not an array"}; in verifyIsArray()
260 * Verifies that the specified JSON element is a JSON object.
262 * Throws an invalid_argument exception if the element is not an object.
264 * @param element JSON element
266 inline void verifyIsObject(const nlohmann::json& element) in verifyIsObject() argument
268 if (!element.is_object()) in verifyIsObject()
270 throw std::invalid_argument{"Element is not an object"}; in verifyIsObject()
275 * Verifies that the specified JSON element contains the expected number of
278 * Throws an invalid_argument exception if the element contains a different
279 * number of properties. This indicates the element contains an invalid
282 * @param element JSON element
283 * @param expectedCount expected number of properties in element
285 inline void verifyPropertyCount(const nlohmann::json& element, in verifyPropertyCount() argument
288 if (element.size() != expectedCount) in verifyPropertyCount()
290 throw std::invalid_argument{"Element contains an invalid property"}; in verifyPropertyCount()