RSC  0.16.0
langutils.h File Reference
#include <string>
#include <boost/cstdint.hpp>
#include <boost/shared_ptr.hpp>
#include "rsc/rscexports.h"
Include dependency graph for langutils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  rsc::misc::NullDeleter
 A deleter object that can be used with boost::shared_ptr that doesn't release any memory. More...
 
class  rsc::misc::ParentSharedPtrDeleter< ParentType >
 A deleter for boost::shared_ptr which enables to use a pointer in a shared_ptr, which is not a shared_ptr itself and owned by another object. More...
 
struct  rsc::misc::detail::true_type
 
struct  rsc::misc::detail::false_type
 
struct  rsc::misc::detail::converter< test >
 
struct  rsc::misc::detail::converter< 0 >
 

Namespaces

 rsc
 
 rsc::misc
 
 rsc::misc::detail
 

Macros

#define DEPRECATED_MSG(func, msg)   func
 This macro allows you to mark a function as being deprecated including a message explaining the deprecation. More...
 
#define DEPRECATED(fun)   DEPRECATED_MSG(fun, "Use of deprecated construct.")
 This macro allows you to mark a function as being deprecated. More...
 
#define DEPRECATED_CLASS(msg)
 This macro allows you to mark a class as being deprecated. More...
 
#define PP_CAT(x, y)   PP_CAT1(x,y)
 
#define PP_CAT1(x, y)   x##y
 
#define STATIC_ASSERT_WARN(cond, msg)
 Generates a compiler warning in case a static condition is not held. More...
 
#define STATIC_ASSERT_WARN_TEMPLATE(token, cond, msg)   STATIC_ASSERT_WARN(cond, msg) PP_CAT(PP_CAT(_localvar_, token),__LINE__)
 Generates a compiler warning in case a static condition is not held. More...
 

Functions

boost::uint64_t rsc::misc::currentTimeMillis ()
 Returns the current system time as milliseconds. More...
 
boost::uint64_t rsc::misc::currentTimeMicros ()
 Returns the current system time as microseconds. More...
 
char rsc::misc::randAlnumChar ()
 Generates a random alpha-numeric character. More...
 
std::string rsc::misc::randAlnumStr (const std::string::size_type &length)
 Generates a random alpha-numeric string with fixed length. More...
 

Macro Definition Documentation

#define DEPRECATED (   fun)    DEPRECATED_MSG(fun, "Use of deprecated construct.")

This macro allows you to mark a function as being deprecated.

A default explanatory message will be used. Usually you should use DEPRECATED_MSG instead.

Usage:

1 DEPRECATED_MSG(void deprecatedFunction(int foo));
2 void deprecatedFunction(int foo) {
3  int bla = foo + 1;
4  bla = bla + 1;
5 }
Note
If your return type contains a comma (template) you need to typedef it. Otherwise the commas are interpreted as arguments to this macro.

Definition at line 168 of file langutils.h.

#define DEPRECATED_CLASS (   msg)

This macro allows you to mark a class as being deprecated.

Usage:

1 class DEPRECATED_CLASS("Your explanation") SimpleDeprecation;
2 class SimpleDeprecation {
3 };
Note
On GCC, a bug might prevent deprecation warnings for template classes

Definition at line 192 of file langutils.h.

#define DEPRECATED_MSG (   func,
  msg 
)    func

This macro allows you to mark a function as being deprecated including a message explaining the deprecation.

Usage:

1 DEPRECATED_MSG(void deprecatedFunction(int foo), "use XYZ instead");
2 void deprecatedFunction(int foo) {
3  int bla = foo + 1;
4  bla = bla + 1;
5 }
Note
If your return type contains a comma (template) you need to typedef it. Otherwise the commas are interpreted as arguments to this macro.

Definition at line 148 of file langutils.h.

#define PP_CAT (   x,
 
)    PP_CAT1(x,y)

Definition at line 198 of file langutils.h.

#define PP_CAT1 (   x,
 
)    x##y

Definition at line 199 of file langutils.h.

#define STATIC_ASSERT_WARN (   cond,
  msg 
)
Value:
struct PP_CAT(static_warning,__LINE__) { \
DEPRECATED_MSG(void _(::rsc::misc::detail::false_type const& ),msg) {}; \
void _(::rsc::misc::detail::true_type const& ) {}; \
PP_CAT(static_warning,__LINE__)() {_(::rsc::misc::detail::converter<(cond)>());} \
}
#define PP_CAT(x, y)
Definition: langutils.h:198
#define DEPRECATED_MSG(func, msg)
This macro allows you to mark a function as being deprecated including a message explaining the depre...
Definition: langutils.h:148

Generates a compiler warning in case a static condition is not held.

Might be used at namespace, structure, and function scope.

Usage:

1 STATIC_ASSERT_WARN(2==3, "Will always warn")
2 STATIC_ASSERT_WARN((!boost::is_same<T, Event>::value), "Illegal type used")
Note
in case you are inside a templated class or function, you might need to use STATIC_ASSERT_WARN_TEMPLATE to really generate a warning.

Definition at line 227 of file langutils.h.

#define STATIC_ASSERT_WARN_TEMPLATE (   token,
  cond,
  msg 
)    STATIC_ASSERT_WARN(cond, msg) PP_CAT(PP_CAT(_localvar_, token),__LINE__)

Generates a compiler warning in case a static condition is not held.

Might be used at namespace, structure, and function scope. The first argument must be a completely unique token.

Usage:

1 STATIC_ASSERT_WARN_TEMPLATE(UNIQUE_TOKEN, 2==3, "Will always warn")
2 STATIC_ASSERT_WARN_TEMPLATE(UNIQUE_TOKEN, (!boost::is_same<T, Event>::value), "Illegal type used")
Note
This macro adds a new member to your type. So try to use STATIC_ASSERT_WARN whenever possible

Definition at line 248 of file langutils.h.