1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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
14 * The Original Code is Mozilla XPCOM Glue.
16 * The Initial Developer of the Original Code is
17 * the Mozilla Foundation <http://www.mozilla.org/>.
19 * Portions created by the Initial Developer are Copyright (C) 2005
20 * the Initial Developer. All Rights Reserved.
23 * Benjamin Smedberg <benjamin@smedbergs.us>
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.
37 * ***** END LICENSE BLOCK ***** */
45 * Scan a string for the first character that is *not* in a set of
46 * delimiters. If the string is only delimiter characters, the end of the
49 * @param delims The set of delimiters (null-terminated)
50 * @param str The string to search (null-terminated)
52 NS_COM_GLUE
const char*
53 NS_strspnp(const char *delims
, const char *str
);
56 * Tokenize a string. This function is similar to the strtok function in the
57 * C standard library, but it does not use static variables to maintain state
58 * and is therefore thread and reentrancy-safe.
60 * Any leading delimiters in str are skipped. Then the string is scanned
61 * until an additional delimiter or end-of-string is found. The final
62 * delimiter is set to '\0'.
64 * @param delims The set of delimiters.
65 * @param str The string to search. This is an in-out parameter; it is
66 * reset to the end of the found token + 1, or to the
67 * end-of-string if there are no more tokens.
68 * @return The token. If no token is found (the string is only
69 * delimiter characters), NULL is returned.
72 NS_strtok(const char *delims
, char **str
);
75 * "strlen" for PRUnichar strings
78 NS_strlen(const PRUnichar
*aString
);
81 * "strcmp" for PRUnichar strings
84 NS_strcmp(const PRUnichar
*a
, const PRUnichar
*b
);
87 * "strdup" for PRUnichar strings, uses the NS_Alloc allocator.
89 NS_COM_GLUE PRUnichar
*
90 NS_strdup(const PRUnichar
*aString
);
93 * "strdup", but using the NS_Alloc allocator.
96 NS_strdup(const char *aString
);
99 * strndup for PRUnichar strings... this function will ensure that the
100 * new string is null-terminated. Uses the NS_Alloc allocator.
102 NS_COM_GLUE PRUnichar
*
103 NS_strndup(const PRUnichar
*aString
, PRUint32 aLen
);
105 // The following case-conversion methods only deal in the ascii repertoire
108 // semi-private data declarations... don't use these directly.
109 class NS_COM_GLUE nsLowerUpperUtils
{
111 static const unsigned char kLower2Upper
[256];
112 static const unsigned char kUpper2Lower
[256];
115 inline char NS_ToUpper(char aChar
)
117 return (char)nsLowerUpperUtils::kLower2Upper
[(unsigned char)aChar
];
120 inline char NS_ToLower(char aChar
)
122 return (char)nsLowerUpperUtils::kUpper2Lower
[(unsigned char)aChar
];
125 NS_COM_GLUE PRBool
NS_IsUpper(char aChar
);
126 NS_COM_GLUE PRBool
NS_IsLower(char aChar
);
128 NS_COM_GLUE PRBool
NS_IsAscii(PRUnichar aChar
);
129 NS_COM_GLUE PRBool
NS_IsAscii(const PRUnichar
* aString
);
130 NS_COM_GLUE PRBool
NS_IsAsciiAlpha(PRUnichar aChar
);
131 NS_COM_GLUE PRBool
NS_IsAsciiDigit(PRUnichar aChar
);
132 NS_COM_GLUE PRBool
NS_IsAsciiWhitespace(PRUnichar aChar
);
133 NS_COM_GLUE PRBool
NS_IsAscii(const char* aString
);
134 NS_COM_GLUE PRBool
NS_IsAscii(const char* aString
, PRUint32 aLength
);
136 #endif // nsCRTGlue_h__