gatelib  2.1
g_common_functions.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "g_common_def.h"
5 #include <string>
6 
7 namespace g
8 {
15  enum MsgBox_t
17  {
26  };
27 
30  {
41  };
42 
44  MsgBoxResult_t G_LIB_ITEM msg_box ( const char* msg , const char* caption = "g::lib" , MsgBox_t type = message_box_type_ok );
45 
47  MsgBoxResult_t G_LIB_ITEM msg_box ( const GWchar_t* msg , const GWchar_t* caption = L"g::lib" , MsgBox_t type = message_box_type_ok );
48 
53  std::string G_LIB_ITEM get_jar_path ( );
54 
55 #if !G_OPTION_HIDE_INCOMPATIBLE
56  MsgBoxResult_t G_LIB_ITEM java_msg_box (
58  const char* aMessage ,
59  const char* aCaption = "g::lib" ,
60  MsgBox_t aMsgBoxType = message_box_type_ok );
61 # ifdef G_AUTOPTION_ON_WINDOWS
62  MsgBoxResult_t G_LIB_ITEM win_msg_box (
64  const char* aMessage ,
65  const char* aCaption = "g::lib" ,
66  MsgBox_t aMsgBoxType = message_box_type_ok );
67 
69  MsgBoxResult_t G_LIB_ITEM win_msg_box (
70  const GWchar_t* aMessage ,
71  const GWchar_t* aCaption = L"g::lib" ,
72  MsgBox_t aMsgBoxType = message_box_type_ok );
73 # endif
74 #endif
75 
77  std::wstring G_LIB_ITEM get_exe_name ( );
78 
80  inline std::string to_StdString(const std::wstring& aString ) { return std::string(aString.begin(),aString.end()); }
81 
83  inline std::wstring to_Wstring(const std::string& aString ) { return std::wstring(aString.begin(),aString.end()); }
84 
104  template < class T > T get_rounded_by_power_of_2 ( T value , T delta )
105  {
106  const T mask = delta-1;
107  const T mask_complementar = ~mask;
108 
109  return delta+((value-1)&mask_complementar);
110  }
113 }//namespace g
114 
115 
116 
Definition: g_common_functions.h:33
MsgBox_t
Types of message box.
Definition: g_common_functions.h:16
MsgBoxResult_t G_LIB_ITEM win_msg_box(const GWchar_t *aMessage, const GWchar_t *aCaption=L"g::lib", MsgBox_t aMsgBoxType=message_box_type_ok)
Launches a windows message box.
Definition: g_common_functions.h:18
Definition: g_common_functions.h:36
Definition: g.mthread.ThreadSimpleEvent.h:5
std::string G_LIB_ITEM get_jar_path()
Definition: g_common_functions.h:23
Definition: g_common_functions.h:32
std::wstring G_LIB_ITEM get_exe_name()
Returns the exe name of THIS application.
Definition: g_common_functions.h:37
Definition: g_common_functions.h:40
Definition: g_common_functions.h:38
Definition: g_common_functions.h:39
Definition: g_common_functions.h:24
std::wstring to_Wstring(const std::string &aString)
Converts a string to a wide strings.
Definition: g_common_functions.h:83
T get_rounded_by_power_of_2(T value, T delta)
f(v,d) is the next multiple of d(MUST be a power of 2), which is k*d>=v && (k-1)*d
Definition: g_common_functions.h:104
MsgBoxResult_t G_LIB_ITEM msg_box(const GWchar_t *msg, const GWchar_t *caption=L"g::lib", MsgBox_t type=message_box_type_ok)
Launches a ( default simple ) message box ( wide char version )
Definition: g_common_functions.h:20
Definition: g_common_functions.h:25
MsgBoxResult_t G_LIB_ITEM java_msg_box(const char *aMessage, const char *aCaption="g::lib", MsgBox_t aMsgBoxType=message_box_type_ok)
Launches a message box "from a jar file".
Definition: g_common_functions.h:21
std::string to_StdString(const std::wstring &aString)
std::wstring to std::string
Definition: g_common_functions.h:80
Definition: g_common_functions.h:19
Definition: g_common_functions.h:34
MsgBoxResult_t
Possible result of a message box call.
Definition: g_common_functions.h:29
Definition: g_common_functions.h:35
Definition: g_common_functions.h:31
Definition: g_common_functions.h:22