Its working!!!

This commit is contained in:
Brad Arant 2021-08-11 21:37:48 -07:00
parent a3ba545c59
commit 1632a41b3e
5 changed files with 67 additions and 59 deletions

View File

@ -48,7 +48,7 @@ namespace coreutils {
if(header.getKey().equals(key)) {
ZString value = header.getValue();
if(valueOnly) {
std::vector<ZString> split = ZString(value).split(ZString((char *)";"));
std::vector<ZString> split = ZString(value).split(";");
value = split[0];
}
return value;
@ -60,10 +60,10 @@ namespace coreutils {
ZString IMFMessage::getHeaderKeyPairValue(ZString headerKey, ZString key) {
ZString value;
ZString psource(getHeader(headerKey, false));
std::vector<ZString> sourcep = psource.split((char *)";");
std::vector<ZString> sourcep = psource.split(";");
for(ZString work: sourcep) {
work.skipWhitespace();
ZString token = work.getTokenExclude((char *)"=");
ZString token = work.getTokenExclude("=");
if(work.ifNext((char *)"=")) {
if(token.equals(key)) {
if(work.ifNext((char *)"\"")) {

View File

@ -4,7 +4,9 @@
namespace coreutils {
std::ostream& operator<<(std::ostream& os, const ZString &zstring) {
os << zstring;
for(int ix = 0; ix < zstring.length; ++ix) {
os << zstring.data[ix];
}
return os;
}
@ -24,18 +26,20 @@ namespace coreutils {
cursor = data;
}
ZString::ZString(const ZString&) {}
ZString::ZString(const char *data) : data((char *)data), length(strlen(data)), cursor((char *)data) {}
ZString::ZString(char *data, size_t length) : data(data), length(length), cursor(data) {}
ZString::ZString(ZString &zstring) {
data = zstring.getData();
length = zstring.getLength();
ZString::ZString(const char *data, size_t length) : data((char *)data), length(length), cursor((char *)data) {}
ZString::ZString(const ZString &zstring) {
data = zstring.data;
length = zstring.length;
cursor = zstring.cursor;
Log(LOG_DEBUG_2) << "ZSrting Copy Constructor: ";
}
std::vector<ZString> & ZString::getList() {
std::vector<ZString> &ZString::getList() {
return list;
}
@ -54,11 +58,12 @@ namespace coreutils {
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(std::string delimiter, size_t maxSize) {
coreutils::ZString zDelimiter((char *)delimiter.c_str(), delimiter.size());
return split(zDelimiter, maxSize);
}
std::vector<ZString> ZString::split(ZString delimiter, size_t maxSize) {
std::vector<ZString> &ZString::split(ZString &delimiter, size_t maxSize) {
list.clear();
if(length == 0) {
list.push_back(ZString((char *)""));
@ -78,25 +83,30 @@ namespace coreutils {
++pos;
}
}
list.push_back(ZString(cursor, pos - cursor));
cursor = pos;
return list;
}
ZString ZString::getTokenInclude(char *include) {
ZString ZString::getTokenInclude(const char *include) {
char *start = cursor;
int len = strcspn(cursor, include);
cursor += len;
return ZString(start, len);
}
ZString ZString::getTokenExclude(char *exclude) {
ZString ZString::getTokenExclude(const char *exclude) {
char *start = cursor;
int len = strspn(cursor, exclude);
cursor += len;
return ZString(start, len);
}
ZString ZString::operator[](int index) {
ZString ZString::getTokenExclude(std::string exclude) {
return getTokenExclude(exclude.c_str());
}
ZString &ZString::operator[](int index) {
return list[index];
}
@ -108,14 +118,14 @@ namespace coreutils {
return strncmp(data, value, length) == 0;
}
bool ZString::equals(ZString zstring) {
bool ZString::equals(ZString &zstring) {
if(zstring.getLength() != getLength())
return false;
return strncmp(data, zstring.getData(), getLength()) == 0;
}
bool ZString::equals(std::string string) {
return strncmp(string.c_str(), getData(), getLength()) == 0;
bool ZString::equals(std::string &string) {
return string == std::string(data, length);
}
bool ZString::ifNext(char *value) {

View File

@ -31,12 +31,6 @@ namespace coreutils {
ZString();
///
/// Copy constructor.
///
ZString(const ZString&);
///
///
///
@ -49,11 +43,13 @@ namespace coreutils {
ZString(char *data, size_t length);
ZString(const char *data, size_t length);
///
/// Consructor providing a copy of a ZString.
///
ZString(ZString &zstring);
ZString(const ZString &zstring);
///
/// A friend method used to write the value of the ZString from the cursor
@ -96,13 +92,13 @@ 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);
std::vector<ZString> &split(std::string delimiter, size_t maxSize = 0);
///
/// Use getTokenInclude with a list of character to allow the forwarding
@ -110,19 +106,21 @@ namespace coreutils {
/// include string is not encountered in the ZString data.
///
ZString getTokenInclude(char *include);
ZString getTokenInclude(const char *include);
///
///
///
ZString getTokenExclude(char *exclude);
ZString getTokenExclude(const char *exclude);
ZString getTokenExclude(std::string exclude);
///
/// Use the [] operator to retrieve values delimited by the split method.
///
ZString operator[](int index);
ZString &operator[](int index);
///
/// Return true if the ZString cursor is at the end of the data.
@ -140,13 +138,13 @@ namespace coreutils {
///
///
bool equals(ZString zstring);
bool equals(ZString &zstring);
///
///
///
bool equals(std::string string);
bool equals(std::string &string);
///
/// Advance the cursor the length of the provided value if the value at

View File

@ -5,7 +5,7 @@ do
filename="${file%.*}"
list="$list $filename.o"
echo -n "Compiling $filename..."
g++ -g -c $file -std=c++17
g++ -g -c $file -std=c++17 &
if [ $? = '0' ]
then
echo "OK"