GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 2 / 0 / 2
Functions: 100.0% 1 / 0 / 1
Branches: -% 0 / 0 / 0

src/utilities/filetypes/StandardsJSON.hpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #ifndef UTILITIES_FILETYPES_STANDARDSJSON_HPP
7 #define UTILITIES_FILETYPES_STANDARDSJSON_HPP
8
9 #include "../UtilitiesAPI.hpp"
10 #include "../core/Logger.hpp"
11
12 namespace Json {
13 class Value;
14 }
15
16 namespace openstudio {
17
18 namespace detail {
19 class StandardsJSON_Impl;
20 }
21
22 /** Class for accessing the OpenStudio Standards (OSW) JSON format. */
23 class UTILITIES_API StandardsJSON
24 {
25 public:
26 // TODO: JM 2018-11-09
27 // Makes no sense really, providing it for SWIG only now
28 StandardsJSON();
29
30 /** Constructor with string, will throw if string is incorrect. */
31 StandardsJSON(const std::string& s);
32
33 /** Clones this StandardsJSON into a separate one. */
34 StandardsJSON clone() const;
35
36 Json::Value toJSON() const;
37
38 /** Get the json as a string. */
39 std::string string() const;
40
41 /** Tries to get the primaryKey, checking that the resulting object is indeed an arrray */
42 boost::optional<Json::Value> getPrimaryKey(const std::string& primaryKey) const;
43
44 /** Attempt to load a StandardsJSON from string */
45 static boost::optional<StandardsJSON> load(const std::string& s);
46
47 protected:
48 // get the impl
49 template <typename T>
50 3 std::shared_ptr<T> getImpl() const {
51 3 return std::dynamic_pointer_cast<T>(m_impl);
52 }
53
54 friend class detail::StandardsJSON_Impl;
55
56 /** Protected constructor from impl. */
57 StandardsJSON(std::shared_ptr<detail::StandardsJSON_Impl> impl);
58
59 private:
60 // configure logging
61 REGISTER_LOGGER("openstudio.StandardsJSON");
62
63 // pointer to implementation
64 std::shared_ptr<detail::StandardsJSON_Impl> m_impl;
65 };
66
67 UTILITIES_API std::ostream& operator<<(std::ostream& os, const StandardsJSON& standardsJSON);
68
69 } // namespace openstudio
70
71 #endif //UTILITIES_FILETYPES_STANDARDSJSON_HPP
72