identity.i (2878B)
1 /* -*- C++ -*- vim: set syntax=cpp: 2 * PURPOSE: 3 * 4 * Provide the implementation of identity string converter functions 5 * for 'char' and 'wchar_t'. 6 * 7 * QUEX_NAME(identical_string)(...) for string and buffer 8 * QUEX_NAME(identical_wstring)(...) for string and buffer 9 * 10 * They exist mainly so that generalized code can be written in a homogenous 11 * manner with the other converter functions. See 'token/CDefault.qx' for example. 12 * 13 * These functions ARE DEPENDENT on QUEX_TYPE_LEXATOM. 14 * => Thus, they are placed in the analyzer's namespace. 15 * 16 * 2010 (C) Frank-Rene Schaefer; 17 * ABSOLUTELY NO WARRANTY */ 18 #if ! defined(__QUEX_INCLUDE_GUARD__CONVERTER_HELPER__IDENTITY_I) \ 19 || defined(__QUEX_INCLUDE_GUARD__CONVERTER_HELPER__TMP_DISABLED) 20 #if ! defined(__QUEX_INCLUDE_GUARD__CONVERTER_HELPER__TMP_DISABLED) 21 # define __QUEX_INCLUDE_GUARD__CONVERTER_HELPER__IDENTITY_I 22 #endif 23 24 #include "identity" 25 26 QUEX_NAMESPACE_MAIN_OPEN 27 28 QUEX_INLINE void 29 QUEX_CONVERTER_STRING_DEF(identical, char)(const QUEX_TYPE_LEXATOM** source_pp, 30 const QUEX_TYPE_LEXATOM* SourceEnd, 31 char** drain_pp, 32 const char* DrainEnd) 33 { 34 const QUEX_TYPE_LEXATOM* from_p = *source_pp; 35 char* to_p = *drain_pp; 36 37 while( from_p != SourceEnd && to_p != DrainEnd ) 38 { 39 *to_p++ = (char)*from_p++; 40 } 41 *source_pp = from_p; 42 *drain_pp = to_p; 43 } 44 45 #if ! defined(__QUEX_OPTION_WCHAR_T_DISABLED) 46 QUEX_INLINE void 47 QUEX_CONVERTER_STRING_DEF(identical, wchar)(const QUEX_TYPE_LEXATOM** source_pp, 48 const QUEX_TYPE_LEXATOM* SourceEnd, 49 wchar_t** drain_pp, 50 const wchar_t* DrainEnd) 51 { 52 const QUEX_TYPE_LEXATOM* from_p = *source_pp; 53 wchar_t* to_p = *drain_pp; 54 55 while( from_p != SourceEnd && to_p != DrainEnd ) 56 { 57 *to_p++ = (wchar_t)*from_p++; 58 } 59 *source_pp = from_p; 60 *drain_pp = to_p; 61 } 62 63 #endif 64 65 #if ! defined(__QUEX_OPTION_PLAIN_C) 66 QUEX_INLINE std::basic_string<char> 67 QUEX_CONVERTER_STRING_DEF(identical, char)(const std::basic_string<QUEX_TYPE_LEXATOM>& Source) 68 { return std::string((const char*)Source.c_str()); } 69 # if ! defined(__QUEX_OPTION_WCHAR_T_DISABLED) 70 QUEX_INLINE std::basic_string<wchar_t> 71 QUEX_CONVERTER_STRING_DEF(identical, wchar)(const std::basic_string<QUEX_TYPE_LEXATOM>& Source) 72 { return std::wstring((const wchar_t*)Source.c_str()); } 73 # endif 74 #endif 75 76 QUEX_NAMESPACE_MAIN_CLOSE 77 78 #endif /* __QUEX_INCLUDE_GUARD__CONVERTER_HELPER__IDENTITY_I */