BasicCharTraits.h++

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002    commonc++ - A C++ Common Class Library
00003    Copyright (C) 2005-2009  Mark A Lindner
00004 
00005    This file is part of commonc++.
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public
00018    License along with this library; if not, write to the Free
00019    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020    ---------------------------------------------------------------------------
00021 */
00022 
00023 #ifndef __ccxx_BasicCharTraits_hxx
00024 #define __ccxx_BasicCharTraits_hxx
00025 
00026 #include <commonc++/Common.h++>
00027 
00028 #include <cstring>
00029 #include <cctype>
00030 #include <cwchar>
00031 #include <cwctype>
00032 #include <cstdarg>
00033 #include <cstdlib>
00034 #include <cstdio>
00035 
00036 namespace ccxx {
00037 
00045 template<typename T> struct BasicCharTraits
00046 {
00052   static size_t length(const T *str) throw();
00053 
00061   static T *copy(T *dest, const T *src, size_t n) throw();
00062 
00072   static T *rawCopy(T *dest, const T *src, size_t n) throw();
00073 
00081   static T *concat(T *dest, const T *src, size_t n) throw();
00082 
00090   static T *move(T *dest, T *src, size_t n) throw();
00091 
00102   static int compare(const T *str1, const T *str2, bool ignoreCase = false)
00103     throw();
00104 
00116   static int rawCompare(const T *str1, const T *str2, size_t n) throw();
00117 
00127   static int collate(const T *str1, const T *str2) throw();
00128 
00140   static int compare(const T *str1, const T *str2, size_t n,
00141                      bool ignoreCase = false) throw();
00142 
00153   static int compare(T c1, T c2, bool ignoreCase = false) throw();
00154 
00162   static size_t span(const T *str, const T *accept) throw();
00163 
00172   static int32_t toLong(const T *str, T **endptr = NULL, int base = 10)
00173     throw();
00174 
00183   static uint32_t toULong(const T *str, T **endptr = NULL, int base = 10)
00184     throw();
00185 
00194   static int64_t toLongLong(const T *str, T **endptr = NULL, int base = 10)
00195     throw();
00196 
00205   static uint64_t toULongLong(const T *str, T **endptr = NULL, int base = 10)
00206     throw();
00207 
00215   static float toFloat(const T *str, T **endptr = NULL) throw();
00216 
00224   static double toDouble(const T *str, T **endptr = NULL) throw();
00225 
00235   static T *find(T *str, T c, size_t len = 0) throw();
00236 
00246   static const T *find(const T *str, T c, size_t len = 0) throw();
00247 
00256   static T *findLast(T *str, T c, uint_t fromIndex = END) throw();
00257 
00266   static const T *findLast(const T *str, T c, uint_t fromIndex = END) throw();
00267 
00275   static T *find(T *str, const T *s) throw();
00276 
00284   static const T *find(const T *str, const T *s) throw();
00285 
00294   static T *findLast(T *str, const T *s, uint_t fromIndex = END) throw();
00295 
00304   static const T *findLast(const T *str, const T *s, uint_t fromIndex = END)
00305     throw();
00306 
00315   static int printf(T *str, size_t len, const T *format, ...) throw();
00316 
00326   static int vprintf(T *str, size_t len, const T *format, va_list vp)
00327     throw();
00328 
00330   static T nul() throw();
00331 
00333   static T plus() throw();
00334 
00336   static T minus() throw();
00337 
00339   static const T *null() throw();
00340 
00342   static const T *empty() throw();
00343 
00345   static const T *whitespace() throw();
00346 
00350   static const T *digits() throw();
00351 
00355   static const T *nullRep() throw();
00356 
00360   static const T *trueRep() throw();
00361 
00365   static const T *falseRep() throw();
00366 
00368   static const T *intFormat() throw();
00369 
00373   static const T *uintFormat() throw();
00374 
00376   static const T *int64Format() throw();
00377 
00381   static const T *uint64Format() throw();
00382 
00386   static const T *doubleFormat() throw();
00387 
00389   static bool isAlpha(T c) throw();
00390 
00392   static bool isAlphaNumeric(T c) throw();
00393 
00395   static bool isWhitespace(T c) throw();
00396 
00398   static bool isPrintable(T c) throw();
00399 
00401   static bool isGraphical(T c) throw();
00402 
00404   static bool isNul(T c) throw();
00405 
00407   static bool isControl(T c) throw();
00408 
00410   static bool isDigit(T c) throw();
00411 
00413   static bool isSign(T c) throw();
00414 
00416   static bool isHexDigit(T c) throw();
00417 
00419   static bool isLowerCase(T c) throw();
00420 
00422   static bool isUpperCase(T c) throw();
00423 
00425   static T toUpperCase(T c) throw();
00426 
00428   static T toLowerCase(T c) throw();
00429 
00434   static T fromInt(int v) throw();
00435 
00440   static int toInt(T c) throw();
00441 
00445   static const char *encoding() throw();
00446 
00448   static const uint_t END = 0xFFFFFFFF;
00449 };
00450 
00451 typedef BasicCharTraits<char> CharTraits;
00452 typedef BasicCharTraits<wchar_t> WCharTraits;
00453 
00454 }; // namespace ccxx
00455 
00456 #endif // __ccxx_BasicCharTraits_hxx
00457 
00458 /* end of header file */

Generated on Sat Apr 17 23:03:05 2010 for libcommonc++ by  doxygen 1.5.9