OSVR-Core
Parameters.h
Go to the documentation of this file.
1 
11 // Copyright 2014 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_Parameters_h_GUID_382472FF_8ED5_429E_6D51_0948F2F403D2
26 #define INCLUDED_Parameters_h_GUID_382472FF_8ED5_429E_6D51_0948F2F403D2
27 
28 // Internal Includes
30 
31 // Library/third-party includes
32 #include <boost/scoped_array.hpp>
33 
34 // Standard includes
35 #include <string>
36 
37 namespace osvr {
38 namespace clientkit {
44  inline std::string getStringParameter(OSVR_ClientContext ctx,
45  const char path[]) {
46  size_t len;
47  osvrClientGetStringParameterLength(ctx, path, &len);
48  std::string ret;
49  if (len == 0) {
50  return ret;
51  }
52  boost::scoped_array<char> buf(new char[len]);
53  osvrClientGetStringParameter(ctx, path, buf.get(), len);
54  ret.assign(buf.get());
55  return ret;
56  }
57 } // namespace clientkit
58 } // namespace osvr
59 
60 #endif // INCLUDED_Parameters_h_GUID_382472FF_8ED5_429E_6D51_0948F2F403D2
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientGetStringParameter(OSVR_ClientContext ctx, const char path[], char *buf, size_t len)
Get a string parameter associated with the given path.
Definition: ParametersC.cpp:49
OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientGetStringParameterLength(OSVR_ClientContext ctx, const char path[], size_t *len)
Get the length of a string parameter associated with the given path.
Definition: ParametersC.cpp:35
Definition: ClientContext.h:50
std::string getStringParameter(OSVR_ClientContext ctx, const char path[])
Get a string parameter value from the given path.
Definition: Parameters.h:44