ZString modifications.
This commit is contained in:
parent
ff2c2b7432
commit
78cb2fdd10
26
ZString.cpp
26
ZString.cpp
@ -8,6 +8,16 @@ namespace coreutils {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& os, const std::string& string) {
|
||||||
|
os << string;
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& operator+(std::ostream& os, const ZString& zstring) {
|
||||||
|
os << zstring;
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
ZString::ZString() {
|
ZString::ZString() {
|
||||||
data = NULL;
|
data = NULL;
|
||||||
length = 0;
|
length = 0;
|
||||||
@ -41,12 +51,16 @@ namespace coreutils {
|
|||||||
std::string ZString::str(int len) {
|
std::string ZString::str(int len) {
|
||||||
return std::string(data, len);
|
return std::string(data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<ZString> ZString::split(std::string &delimiter, size_t maxSize) {
|
||||||
|
return split(ZString(delimiter.c_str()), maxSize);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<ZString> ZString::split(ZString delimiter, size_t maxSize) {
|
std::vector<ZString> ZString::split(ZString delimiter, size_t maxSize) {
|
||||||
list.clear();
|
list.clear();
|
||||||
if(length == 0) {
|
if(length == 0) {
|
||||||
list.push_back(ZString((char *)""));
|
list.push_back(ZString((char *)""));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *end = data + length;
|
char *end = data + length;
|
||||||
@ -94,9 +108,13 @@ namespace coreutils {
|
|||||||
|
|
||||||
bool ZString::equals(ZString zstring) {
|
bool ZString::equals(ZString zstring) {
|
||||||
if(zstring.getLength() != getLength())
|
if(zstring.getLength() != getLength())
|
||||||
return false;
|
return false;
|
||||||
return strncmp(data, zstring.getData(), getLength()) == 0;
|
return strncmp(data, zstring.getData(), getLength()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZString::equals(std::string string) {
|
||||||
|
return strncmp(string.c_str(), getData(), getLength()) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool ZString::ifNext(char *value) {
|
bool ZString::ifNext(char *value) {
|
||||||
bool test = (strncmp(cursor, value, strlen(value)) == 0);
|
bool test = (strncmp(cursor, value, strlen(value)) == 0);
|
||||||
|
17
ZString.h
17
ZString.h
@ -61,7 +61,10 @@ namespace coreutils {
|
|||||||
///
|
///
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& os, const ZString& zstring);
|
friend std::ostream& operator<<(std::ostream& os, const ZString& zstring);
|
||||||
|
friend std::ostream& operator<<(std::ostream& os, const std::string& string);
|
||||||
|
|
||||||
|
friend std::ostream& operator+(std::ostream& os, const ZString& zstring);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Return a vector of ZString objects which contain the parts established
|
/// Return a vector of ZString objects which contain the parts established
|
||||||
/// by using the split method and passing a delimiter value.
|
/// by using the split method and passing a delimiter value.
|
||||||
@ -95,6 +98,12 @@ namespace coreutils {
|
|||||||
|
|
||||||
std::vector<ZString> split(ZString delimiter, size_t maxSize = 0);
|
std::vector<ZString> split(ZString delimiter, size_t maxSize = 0);
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
|
||||||
|
std::vector<ZString> split(std::string &delimiter, size_t maxSize = 0);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Use getTokenInclude with a list of character to allow the forwarding
|
/// Use getTokenInclude with a list of character to allow the forwarding
|
||||||
/// of the cursor through the data until a character that is not in the
|
/// of the cursor through the data until a character that is not in the
|
||||||
@ -133,6 +142,12 @@ namespace coreutils {
|
|||||||
|
|
||||||
bool equals(ZString zstring);
|
bool equals(ZString zstring);
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
|
||||||
|
bool equals(std::string string);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Advance the cursor the length of the provided value if the value at
|
/// Advance the cursor the length of the provided value if the value at
|
||||||
/// the cursor position is equal to the value provided.
|
/// the cursor position is equal to the value provided.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user