00001 #ifndef GLIM_COSTRLEN_HPP_ 00002 #define GLIM_COSTRLEN_HPP_ 00003 00004 /** 00005 * Defines a macro for obtaining the size out of a compiled-in C string. 00006 * This macro allows to avoid the strlen overhead for strings known at compile-time.\n 00007 * Usage example: 00008 * @code 00009 * void doSomething(char const* str, int strLen); 00010 * void someFunc() { 00011 * std::pair<char const*, int> str = S("some text"); 00012 * doSomething (str.first, str.second); 00013 * } 00014 * @endcode 00015 * @file 00016 */ 00017 00018 #include <utility> 00019 #undef S 00020 /** 00021 * This macro allows to avoid the strlen overhead for strings known at compile-time. 00022 */ 00023 #define S(conststring) std::pair<char const*, int>(conststring, sizeof(conststring) - 1) 00024 00025 #endif // GLIM_COSTRLEN_HPP_
1.4.6