PageRenderTime 43ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/gecko_api/include/nsCRTGlue.h

http://firefox-mac-pdf.googlecode.com/
C Header | 136 lines | 40 code | 16 blank | 80 comment | 0 complexity | f82430300a341483735d7965dd2bd848 MD5 | raw file
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is Mozilla XPCOM Glue.
  15. *
  16. * The Initial Developer of the Original Code is
  17. * the Mozilla Foundation <http://www.mozilla.org/>.
  18. *
  19. * Portions created by the Initial Developer are Copyright (C) 2005
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. * Benjamin Smedberg <benjamin@smedbergs.us>
  24. *
  25. * Alternatively, the contents of this file may be used under the terms of
  26. * either the GNU General Public License Version 2 or later (the "GPL"), or
  27. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. * in which case the provisions of the GPL or the LGPL are applicable instead
  29. * of those above. If you wish to allow use of your version of this file only
  30. * under the terms of either the GPL or the LGPL, and not to allow others to
  31. * use your version of this file under the terms of the MPL, indicate your
  32. * decision by deleting the provisions above and replace them with the notice
  33. * and other provisions required by the GPL or the LGPL. If you do not delete
  34. * the provisions above, a recipient may use your version of this file under
  35. * the terms of any one of the MPL, the GPL or the LGPL.
  36. *
  37. * ***** END LICENSE BLOCK ***** */
  38. #ifndef nsCRTGlue_h__
  39. #define nsCRTGlue_h__
  40. #include "nscore.h"
  41. /**
  42. * Scan a string for the first character that is *not* in a set of
  43. * delimiters. If the string is only delimiter characters, the end of the
  44. * string is returned.
  45. *
  46. * @param delims The set of delimiters (null-terminated)
  47. * @param str The string to search (null-terminated)
  48. */
  49. NS_COM_GLUE const char*
  50. NS_strspnp(const char *delims, const char *str);
  51. /**
  52. * Tokenize a string. This function is similar to the strtok function in the
  53. * C standard library, but it does not use static variables to maintain state
  54. * and is therefore thread and reentrancy-safe.
  55. *
  56. * Any leading delimiters in str are skipped. Then the string is scanned
  57. * until an additional delimiter or end-of-string is found. The final
  58. * delimiter is set to '\0'.
  59. *
  60. * @param delims The set of delimiters.
  61. * @param str The string to search. This is an in-out parameter; it is
  62. * reset to the end of the found token + 1, or to the
  63. * end-of-string if there are no more tokens.
  64. * @return The token. If no token is found (the string is only
  65. * delimiter characters), NULL is returned.
  66. */
  67. NS_COM_GLUE char*
  68. NS_strtok(const char *delims, char **str);
  69. /**
  70. * "strlen" for PRUnichar strings
  71. */
  72. NS_COM_GLUE PRUint32
  73. NS_strlen(const PRUnichar *aString);
  74. /**
  75. * "strcmp" for PRUnichar strings
  76. */
  77. NS_COM_GLUE int
  78. NS_strcmp(const PRUnichar *a, const PRUnichar *b);
  79. /**
  80. * "strdup" for PRUnichar strings, uses the NS_Alloc allocator.
  81. */
  82. NS_COM_GLUE PRUnichar*
  83. NS_strdup(const PRUnichar *aString);
  84. /**
  85. * "strdup", but using the NS_Alloc allocator.
  86. */
  87. NS_COM_GLUE char*
  88. NS_strdup(const char *aString);
  89. /**
  90. * strndup for PRUnichar strings... this function will ensure that the
  91. * new string is null-terminated. Uses the NS_Alloc allocator.
  92. */
  93. NS_COM_GLUE PRUnichar*
  94. NS_strndup(const PRUnichar *aString, PRUint32 aLen);
  95. // The following case-conversion methods only deal in the ascii repertoire
  96. // A-Z and a-z
  97. // semi-private data declarations... don't use these directly.
  98. class NS_COM_GLUE nsLowerUpperUtils {
  99. public:
  100. static const unsigned char kLower2Upper[256];
  101. static const unsigned char kUpper2Lower[256];
  102. };
  103. inline char NS_ToUpper(char aChar)
  104. {
  105. return (char)nsLowerUpperUtils::kLower2Upper[(unsigned char)aChar];
  106. }
  107. inline char NS_ToLower(char aChar)
  108. {
  109. return (char)nsLowerUpperUtils::kUpper2Lower[(unsigned char)aChar];
  110. }
  111. NS_COM_GLUE PRBool NS_IsUpper(char aChar);
  112. NS_COM_GLUE PRBool NS_IsLower(char aChar);
  113. NS_COM_GLUE PRBool NS_IsAscii(PRUnichar aChar);
  114. NS_COM_GLUE PRBool NS_IsAscii(const PRUnichar* aString);
  115. NS_COM_GLUE PRBool NS_IsAsciiAlpha(PRUnichar aChar);
  116. NS_COM_GLUE PRBool NS_IsAsciiDigit(PRUnichar aChar);
  117. NS_COM_GLUE PRBool NS_IsAsciiWhitespace(PRUnichar aChar);
  118. NS_COM_GLUE PRBool NS_IsAscii(const char* aString);
  119. NS_COM_GLUE PRBool NS_IsAscii(const char* aString, PRUint32 aLength);
  120. #endif // nsCRTGlue_h__