// ========================================================= //
//                                                           //
//   File      : stringize.h                                 //
//   Purpose   : stringize et.al.                            //
//                                                           //
//   Coded by Ralf Westram (coder@reallysoft.de) in Jan 22   //
//   http://www.arb-home.de/                                 //
//                                                           //
// ========================================================= //

#ifndef STRINGIZE_H
#define STRINGIZE_H

// see also: https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html
//           https://gcc.gnu.org/onlinedocs/cpp/Argument-Prescan.html
//
// unittests are available in ../SL/HEADERTESTS/tiny.cxx@TEST_stringize

// --------------------------------------------------------------------------------
// convert an ID or its prescanned value into a string
//
// #define VALUE 7
// stringize(VALUE)       -> "VALUE"
// stringize_pscan(VALUE) -> "7"
//
// Note: if VALUE is not defined -> stringize_pscan() results in "VALUE"!

// unittests are available in ../SL/HEADERTESTS/tiny.cxx@TEST_stringize

#define stringize(s)       #s
#define stringize_pscan(s) stringize(s)


// --------------------------------------------------------------------------------
// concatenate IDs
//
// #define PREFIX pre_
// #define SUFFIX suf
// concatenate(PREFIX,SUFFIX)                    -> PREFIXSUFFIX
// stringize_pscan(concatenate(PREFIX,SUFFIX))   -> "PREFIXSUFFIX"
// concatenate_pscans(PREFIX,SUFFIX)             -> pre_suf

#define concatenate(a,b)        a##b
#define concatenate_pscans(a,b) concatenate(a,b)


#else
#error stringize.h included twice
#endif // STRINGIZE_H

