OGLplus (0.52.0) a C++ wrapper for OpenGL

application.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_OPT_APPLICATION_1107121519_HPP
14 #define OGLPLUS_OPT_APPLICATION_1107121519_HPP
15 
16 #include <oglplus/config/compiler.hpp>
17 #include <oglplus/utils/filesystem.hpp>
18 
19 #include <string>
20 #include <cassert>
21 
22 namespace oglplus {
23 
25 
30 {
31 private:
32  static std::string& _app_rel_path(void)
33  OGLPLUS_NOEXCEPT(true)
34  {
35  static std::string str;
36  return str;
37  }
38 
39  static std::string& _app_name(void)
40  OGLPLUS_NOEXCEPT(true)
41  {
42  static std::string str;
43  return str;
44  }
45 public:
46 #if !OGLPLUS_NO_DEFAULTED_FUNCTIONS
47  Application(void) = default;
49 
51  Application(const Application&) = delete;
52 #else
53  Application(void){ }
54 private:
55  Application(const Application&);
56 public:
57 
58 #endif
59 
60  static void ParseCommandLineOptions(int argc, const char** argv)
61  {
62  OGLPLUS_FAKE_USE(argc);
63  assert(argc > 0);
64  assert(argv != 0);
65  assert(argv[0] != 0);
66  assert(*argv[0] != 0);
67  // now find the last separator
68  const char* p = argv[0];
69  const char* s = 0;
70  while(*p)
71  {
72  if(aux::IsFilesysPathSep(p, 1)) s = p;
73  ++p;
74  }
75  // if found
76  if(s != 0)
77  {
78  assert(s != p);
79  _app_rel_path() = std::string(argv[0], s+1);
80  _app_name() = std::string(s+1, p);
81  }
82  else _app_name() = std::string(argv[0], p);
83  }
84 
85  static void ParseCommandLineOptions(int argc, char** argv)
86  {
87  ParseCommandLineOptions(argc, (const char**)argv);
88  }
89 
91 
95  static const std::string& RelativePath(void)
96  OGLPLUS_NOEXCEPT(true)
97  {
98  return _app_rel_path();
99  }
100 
102  static const std::string& Name(void)
103  OGLPLUS_NOEXCEPT(true)
104  {
105  return _app_name();
106  }
107 };
108 
109 } // namespace oglplus
110 
111 #endif // include guard
A monostate class wrapping application and startup options-related things.
Definition: application.hpp:29
static const std::string & RelativePath(void)
Returns the path relative to the applications executable from CWD.
Definition: application.hpp:95
Application(void)=default
Default constructor.
static const std::string & Name(void)
Returns the application executable base name.
Definition: application.hpp:102

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).