DDS  ver. 3.4
BOOSTHelper.h
Go to the documentation of this file.
1 // Copyright 2014 GSI, Inc. All rights reserved.
2 //
3 // Helpers for BOOST libraries
4 //
5 #ifndef BOOSTHELPER_H_
6 #define BOOSTHELPER_H_
7 
8 // BOOST
9 // FIX: silence a warning until BOOST fix it
10 // boost/thread/pthread/condition_variable.hpp:53:19: warning: unused variable 'res' [-Wunused-variable]
11 // clang
12 #ifdef __clang__
13 #pragma clang diagnostic push
14 #pragma clang diagnostic ignored "-Wunused-variable"
15 #endif
16 // gcc
17 #if defined(__GNUG__) && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
18 // push doesn't work for gcc 4.2
19 //#pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wunused-variable"
21 #endif
22 #include <boost/thread/thread.hpp>
23 #ifdef __clang__
24 #pragma clang diagnostic pop
25 #endif
26 #if defined(__GNUG__) && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
27 //#pragma GCC diagnostic pop
28 #pragma GCC diagnostic warning "-Wunused-variable"
29 #endif
30 
31 #include <boost/program_options/variables_map.hpp>
32 #include <boost/shared_ptr.hpp>
33 // MiscCommon
34 #include "MiscUtils.h"
35 
36 namespace MiscCommon
37 {
43  namespace BOOSTHelper
44  {
50  typedef boost::shared_ptr<boost::thread> Thread_PTR_t;
62  inline void conflicting_options(const boost::program_options::variables_map& _vm,
63  const char* _opt1,
64  const char* _opt2)
65  {
66  if (_vm.count(_opt1) && !_vm[_opt1].defaulted() && _vm.count(_opt2) && !_vm[_opt2].defaulted())
67  {
68  std::string str("Command line parameter \"%1\" conflicts with \"%2\"");
69  MiscCommon::replace<std::string>(&str, "%1", _opt1);
70  MiscCommon::replace<std::string>(&str, "%2", _opt2);
71  throw std::runtime_error(str);
72  }
73  }
85  inline void option_dependency(const boost::program_options::variables_map& _vm,
86  const char* _for_what,
87  const char* _required_option)
88  {
89  if (_vm.count(_for_what) && !_vm[_for_what].defaulted() &&
90  (!_vm.count(_required_option) || _vm[_required_option].defaulted()))
91  {
92  std::string str("Command line parameter \"%1\" must be used with \"%2\"");
93  MiscCommon::replace<std::string>(&str, "%1", _for_what);
94  MiscCommon::replace<std::string>(&str, "%2", _required_option);
95  throw std::runtime_error(str);
96  }
97  }
98  }; // namespace BOOSTHelper
99 }; // namespace MiscCommon
100 
101 #endif /*BOOSTHELPER_H_*/
boost::shared_ptr< boost::thread > Thread_PTR_t
A smart pointer wrapper for boost::thread pointers.
Definition: BOOSTHelper.h:50
void option_dependency(const boost::program_options::variables_map &_vm, const char *_for_what, const char *_required_option)
The option_dependency function used to check that if 'for_what' is specified, then 'required_option' ...
Definition: BOOSTHelper.h:85
void conflicting_options(const boost::program_options::variables_map &_vm, const char *_opt1, const char *_opt2)
The conflicting_options function used to check that 'opt1' and 'opt2' are not specified at the same t...
Definition: BOOSTHelper.h:62
Miscellaneous functions and helpers are located here.
Definition: BOOST_FILESYSTEM.h:21