OSVR-Core
JSONResolvePossibleRef.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_JSONResolvePossibleRef_h_GUID_64F277A1_33F0_4986_6EEE_09E17C09AA52
26 #define INCLUDED_JSONResolvePossibleRef_h_GUID_64F277A1_33F0_4986_6EEE_09E17C09AA52
27 
28 // Internal Includes
30 
31 // Library/third-party includes
32 #include <json/value.h>
33 
34 // Standard includes
35 #include <vector>
36 #include <string>
37 
38 namespace osvr {
39 namespace server {
40  enum class FileLoadStatus {
41  CouldNotOpenFile,
42  CouldNotParseFile,
43  FileOpenedAndParsed
44  };
45  enum class ValueHandledAs { Filename, String, JsonRefToFile, Other };
46  struct FileLoadAttempt {
47  std::string path;
48  FileLoadStatus status;
49  std::string details;
50  };
51  using FileLoadAttempts = std::vector<FileLoadAttempt>;
52 
54  Json::Value result;
55  bool resolved = false;
56  ValueHandledAs handledAs = ValueHandledAs::Other;
57  FileLoadAttempts fileAttempts;
58  };
59 
60  const char *fileLoadStatusToString(FileLoadStatus status);
61 
75  Json::Value resolvePossibleRef(
76  Json::Value const &input, bool stringAcceptableResult = false,
77  std::vector<std::string> const &searchPath = getConfigDirectories());
78 
80  Json::Value const &input, bool stringAcceptableResult = false,
81  std::vector<std::string> const &searchPath = getConfigDirectories());
82 
83 } // namespace server
84 } // namespace osvr
85 
86 #endif // INCLUDED_JSONResolvePossibleRef_h_GUID_64F277A1_33F0_4986_6EEE_09E17C09AA52
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Definition: JSONResolvePossibleRef.h:53
Definition: JSONResolvePossibleRef.h:46
OSVR_SERVER_EXPORT std::vector< std::string > getConfigDirectories()
Get list of directories to search for config files.
Definition: ConfigFilePaths.cpp:42
ResolveRefResult resolvePossibleRefWithDetails(Json::Value const &input, bool stringAcceptableResult, std::vector< std::string > const &searchPath)
Definition: JSONResolvePossibleRef.cpp:101
Platform specific search paths for osvr server config files.
Json::Value resolvePossibleRef(Json::Value const &input, bool stringAcceptableResult, std::vector< std::string > const &searchPath)
Given an input that might be a filename, might be a JSON Pointer-style $ref object, and might just directly be an object, return the object desired.
Definition: JSONResolvePossibleRef.cpp:138