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

@ -8,9 +8,9 @@ namespace coreutils {
this->file = file; this->file = file;
this->line = line; this->line = line;
if(errorNumber == -1) if(errorNumber == -1)
this->errorNumber = errno; this->errorNumber = errno;
else else
this->errorNumber = errorNumber; this->errorNumber = errorNumber;
Log(LOG_EXCEPT) << text; Log(LOG_EXCEPT) << text;
} }

View File

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

View File

@ -4,7 +4,9 @@
namespace coreutils { namespace coreutils {
std::ostream& operator<<(std::ostream& os, const ZString &zstring) { 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; return os;
} }
@ -24,18 +26,20 @@ namespace coreutils {
cursor = data; cursor = data;
} }
ZString::ZString(const ZString&) {}
ZString::ZString(const char *data) : data((char *)data), length(strlen(data)), cursor((char *)data) {} 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(char *data, size_t length) : data(data), length(length), cursor(data) {}
ZString::ZString(ZString &zstring) { ZString::ZString(const char *data, size_t length) : data((char *)data), length(length), cursor((char *)data) {}
data = zstring.getData();
length = zstring.getLength(); 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; return list;
} }
@ -54,11 +58,12 @@ namespace coreutils {
return std::string(data, len); return std::string(data, len);
} }
std::vector<ZString> ZString::split(std::string &delimiter, size_t maxSize) { std::vector<ZString> &ZString::split(std::string delimiter, size_t maxSize) {
return split(ZString(delimiter.c_str()), 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(); list.clear();
if(length == 0) { if(length == 0) {
list.push_back(ZString((char *)"")); list.push_back(ZString((char *)""));
@ -70,33 +75,38 @@ namespace coreutils {
while(pos < end) { while(pos < end) {
if(strncmp(pos, delimiter.getData(), delimiter.getLength()) == 0) { if(strncmp(pos, delimiter.getData(), delimiter.getLength()) == 0) {
list.push_back(ZString(cursor, pos - cursor)); list.push_back(ZString(cursor, pos - cursor));
cursor = pos + delimiter.getLength(); cursor = pos + delimiter.getLength();
pos = cursor; pos = cursor;
} }
else { else {
++pos; ++pos;
} }
} }
list.push_back(ZString(cursor, pos - cursor));
cursor = pos; cursor = pos;
return list; return list;
} }
ZString ZString::getTokenInclude(char *include) { ZString ZString::getTokenInclude(const char *include) {
char *start = cursor; char *start = cursor;
int len = strcspn(cursor, include); int len = strcspn(cursor, include);
cursor += len; cursor += len;
return ZString(start, len); return ZString(start, len);
} }
ZString ZString::getTokenExclude(char *exclude) { ZString ZString::getTokenExclude(const char *exclude) {
char *start = cursor; char *start = cursor;
int len = strspn(cursor, exclude); int len = strspn(cursor, exclude);
cursor += len; cursor += len;
return ZString(start, 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]; return list[index];
} }
@ -108,14 +118,14 @@ namespace coreutils {
return strncmp(data, value, length) == 0; return strncmp(data, value, length) == 0;
} }
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) { bool ZString::equals(std::string &string) {
return strncmp(string.c_str(), getData(), getLength()) == 0; return string == std::string(data, length);
} }
bool ZString::ifNext(char *value) { bool ZString::ifNext(char *value) {

View File

@ -31,12 +31,6 @@ namespace coreutils {
ZString(); ZString();
///
/// Copy constructor.
///
ZString(const ZString&);
/// ///
/// ///
/// ///
@ -49,11 +43,13 @@ namespace coreutils {
ZString(char *data, size_t length); ZString(char *data, size_t length);
ZString(const char *data, size_t length);
/// ///
/// Consructor providing a copy of a ZString. /// 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 /// 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 /// 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. /// 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. /// 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. /// 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 /// Advance the cursor the length of the provided value if the value at

View File

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