StrUtil.h
/*
* $Id: StrUtil.h 3427 2012-10-08 12:55:32Z karijes $
*
* Basic functions for C string handling
* Copyright (c) 2005-2007 edelib authors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EDELIB_STRUTIL_H__
#define __EDELIB_STRUTIL_H__
#include "String.h"
EDELIB_NS_BEGIN
EDELIB_API char* str_trimleft(char* str);
EDELIB_API char* str_trimright(char* str);
EDELIB_API char* str_trim(char* str);
EDELIB_API unsigned char* str_tolower(unsigned char* str);
EDELIB_API unsigned char* str_toupper(unsigned char* str);
EDELIB_API bool str_ends(const char* str, const char* test);
EDELIB_API unsigned int str_hash(const char* str, unsigned int len = 0);
template <typename Container>
void stringtok(Container& c, const String& str, const char* ws = " \t\n") {
const String::size_type sz = str.length();
String::size_type i = 0, j = 0;
while(i < sz) {
while((i < sz) && (strchr(ws, str[i]) != NULL))
i++;
if(i == sz)
return;
j = i + 1;
while((j < sz) && (strchr(ws, str[j]) == NULL))
j++;
c.push_back(str.substr(i, j-i));
i = j + 1;
}
}
EDELIB_NS_END
#endif
edelib::str_toupper
unsigned char * str_toupper(unsigned char *str)
edelib::str_trim
char * str_trim(char *str)
edelib::str_hash
unsigned int str_hash(const char *str, unsigned int len=0)
edelib::str_tolower
unsigned char * str_tolower(unsigned char *str)
edelib::str_trimleft
char * str_trimleft(char *str)
edelib::String::length
size_type length(void) const
Definition: String.h:292
edelib::String::substr
String substr(size_type index, size_type num=npos) const
edelib::String
A (relatively simple) string implementation.
Definition: String.h:82
edelib::str_trimright
char * str_trimright(char *str)
edelib::stringtok
void stringtok(Container &c, const String &str, const char *ws=" \t\n")
Definition: StrUtil.h:86
edelib::str_ends
bool str_ends(const char *str, const char *test)