OSVR-Core  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ProgramOptionsToggleFlags.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_ProgramOptionsToggleFlags_h_GUID_9879F3E3_4C35_4389_010C_FD82D5878172
26 #define INCLUDED_ProgramOptionsToggleFlags_h_GUID_9879F3E3_4C35_4389_010C_FD82D5878172
27 
28 // Internal Includes
29 // - none
30 
31 // Library/third-party includes
32 // - none
33 
34 // Standard includes
35 #include <string>
36 #include <utility>
37 
38 namespace osvr {
39 namespace util {
42  inline std::pair<std::string, std::string>
44  static const char HIDE[] = "--hide-";
45  static const char SHOW[] = "--show-";
46  if (0 == s.find(SHOW)) {
47  // argument started with --show-
48  // strip it off to get the real option and give it the value "true"
49  s.erase(0, sizeof(SHOW) - 1);
50  return std::make_pair(s, std::string("true"));
51  } else if (0 == s.find(HIDE)) {
52  // argument started with --hide-
53  // strip it off to get the real option and give it the value "false"
54  s.erase(0, sizeof(HIDE) - 1);
55  return std::make_pair(s, std::string("false"));
56  }
57  // program option we weren't able to add value to.
58  return std::make_pair(std::string(), std::string());
59  }
60 } // namespace util
61 } // namespace osvr
62 
63 #endif // INCLUDED_ProgramOptionsToggleFlags_h_GUID_9879F3E3_4C35_4389_010C_FD82D5878172
The main namespace for all C++ elements of the framework, internal and external.
Definition: ClientKit.h:31
std::pair< std::string, std::string > convertProgramOptionShowHideIntoTrueFalse(std::string s)
An "additional parser" for Boost.Program_options that will turn any –hide-xyz into –xyz false and â€...