KUDr@7116: /* $Id$ */ KUDr@7116: KUDr@7116: /** @file strapi.hpp */ KUDr@7116: KUDr@7116: #ifndef STRAPI_HPP KUDr@7116: #define STRAPI_HPP KUDr@7116: KUDr@7116: #include rubidium@7255: rubidium@7255: #if defined(HAS_WCHAR) KUDr@7116: #include KUDr@7116: KUDr@7116: #if !defined(_MSC_VER) KUDr@7116: #define _stricmp strcmp KUDr@7116: #define _wcsicmp wcscmp rubidium@7255: #endif /* !defined(_MSC_VER) */ rubidium@7255: #endif /* HAS_WCHAR */ KUDr@7116: KUDr@7116: /** String API mapper base - just mapping by character type, not by case sensitivity yet. KUDr@7116: * Class template CStrApiBaseT declaration is general, but following inline method KUDr@7116: * definitions are specialized by character type. Class is not used directly, but only KUDr@7116: * as a base class for template class CStrApiT */ KUDr@7116: template KUDr@7116: class CStrApiBaseT KUDr@7116: { KUDr@7116: public: KUDr@7116: /** ::strlen wrapper */ KUDr@7116: static size_t StrLen(const Tchar *s); KUDr@7116: static int SPrintFL(Tchar *buf, size_t count, const Tchar *fmt, va_list args); KUDr@7116: }; KUDr@7116: KUDr@7116: /** ::strlen wrapper specialization for char */ KUDr@7116: template <> /*static*/ inline size_t CStrApiBaseT::StrLen(const char *s) KUDr@7116: { KUDr@7116: return ::strlen(s); KUDr@7116: } KUDr@7116: KUDr@7116: /** ::vsprintf wrapper specialization for char */ KUDr@7116: template <> /*static*/ inline int CStrApiBaseT::SPrintFL(char *buf, size_t count, const char *fmt, va_list args) KUDr@7116: { truelight@7405: #if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(WINCE) // VC 8.0 and above KUDr@7116: return ::vsnprintf_s(buf, count, count - 1, fmt, args); rubidium@7255: #else /* ! VC 8.0 and above */ KUDr@7116: return ::vsnprintf(buf, count, fmt, args); KUDr@7116: #endif KUDr@7116: } KUDr@7116: rubidium@7255: #if defined(HAS_WCHAR) rubidium@7255: /** ::strlen wrapper specialization for wchar_t */ rubidium@7255: template <> /*static*/ inline size_t CStrApiBaseT::StrLen(const wchar_t *s) rubidium@7255: { rubidium@7255: return ::wcslen(s); rubidium@7255: } rubidium@7255: KUDr@7116: /** ::vsprintf wrapper specialization for wchar_t */ KUDr@7116: template <> /*static*/ inline int CStrApiBaseT::SPrintFL(wchar_t *buf, size_t count, const wchar_t *fmt, va_list args) KUDr@7116: { truelight@7405: #if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(WINCE) // VC 8.0 and above KUDr@7116: return ::_vsnwprintf_s(buf, count, count - 1, fmt, args); rubidium@7255: #else /* ! VC 8.0 and above */ KUDr@7116: # if defined(_WIN32) KUDr@7116: return ::_vsnwprintf(buf, count, fmt, args); rubidium@7255: # else /* !_WIN32 */ KUDr@7116: return ::vswprintf(buf, count, fmt, args); rubidium@7255: # endif /* !_WIN32 */ KUDr@7116: #endif KUDr@7116: } rubidium@7255: #endif /* HAS_WCHAR */ KUDr@7116: KUDr@7116: KUDr@7116: KUDr@7116: template KUDr@7116: class CStrApiT : public CStrApiBaseT KUDr@7116: { KUDr@7116: public: KUDr@7116: static int StrCmp(const Tchar *s1, const Tchar *s2); KUDr@7116: }; KUDr@7116: KUDr@7116: template <> /*static*/ inline int CStrApiT::StrCmp(const char *s1, const char *s2) KUDr@7116: { KUDr@7116: return ::strcmp(s1, s2); KUDr@7116: } KUDr@7116: KUDr@7116: template <> /*static*/ inline int CStrApiT::StrCmp(const char *s1, const char *s2) KUDr@7116: { KUDr@7116: return ::_stricmp(s1, s2); KUDr@7116: } KUDr@7116: rubidium@7255: #if defined(HAS_WCHAR) KUDr@7116: template <> /*static*/ inline int CStrApiT::StrCmp(const wchar_t *s1, const wchar_t *s2) KUDr@7116: { KUDr@7116: return ::wcscmp(s1, s2); KUDr@7116: } KUDr@7116: KUDr@7116: template <> /*static*/ inline int CStrApiT::StrCmp(const wchar_t *s1, const wchar_t *s2) KUDr@7116: { KUDr@7116: return ::_wcsicmp(s1, s2); KUDr@7116: } rubidium@7255: #endif /* HAS_WCHAR */ KUDr@7116: KUDr@7116: #endif /* STRAPI_HPP */