// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.

#ifndef tools_S_STRING
#define tools_S_STRING

// a few place in which a cpp macro help the readability.

#include <string>

#define TOOLS_CLASS_STRING(a_name)\
static const std::string& s_##a_name() {\
  static const std::string s_v(#a_name);\
  return s_v;\
}

#define TOOLS_CLASS_STRING_VALUE(a_name,a_value)\
static const std::string& s_##a_name() {\
  static const std::string s_v(#a_value);\
  return s_v;\
}

#define TOOLS_CLASS_STRING_SVALUE(a_name,a_value)\
static const std::string& s_##a_name() {\
  static const std::string s_v(a_value);\
  return s_v;\
}

#define TOOLS_GLOBAL_STRING(a_name)\
inline const std::string& s_##a_name() {\
  static const std::string s_v(#a_name);\
  return s_v;\
}

#define TOOLS_GLOBAL_STRING_VALUE(a_name,a_value)\
inline const std::string& s_##a_name() {\
  static const std::string s_v(#a_value);\
  return s_v;\
}

#define TOOLS_SCLASS(a_name)\
static const std::string& s_class() {\
  static const std::string s_v(#a_name);\
  return s_v;\
}\
static void check_class_name() {a_name::s_class();}

#define TOOLS_T_SCLASS(a_T,a_name)\
static const std::string& s_class() {\
  static const std::string s_v(#a_name);\
  return s_v;\
}\
static void check_class_name() {a_name<a_T>::s_class();}

#define TOOLS_T2_SCLASS(a_T1,a_T2,a_name)\
static const std::string& s_class() {\
  static const std::string s_v(#a_name);\
  return s_v;\
}\
static void check_class_name() {a_name<a_T1,a_T2>::s_class();}

#define TOOLS_T3_SCLASS(a_T1,a_T2,a_T3,a_name)\
static const std::string& s_class() {\
  static const std::string s_v(#a_name);\
  return s_v;\
}\
static void check_class_name() {a_name<a_T1,a_T2,a_T3>::s_class();}

// to transform the value of a cpp macro to a string :
#define TOOLS_CPP_TO__STRING(a_cpp) #a_cpp
#define TOOLS_CPP_TO_STRING(a_cpp) std::string(TOOLS_CPP_TO__STRING(a_cpp))
// for example :
// #define FOO foo
//    std::cout << TOOLS_CPP_TO_STRING(FOO) << std::endl;

#endif
