Updated and working.
This commit is contained in:
1 parent
d4148b0ab4
commit
a37c4e6829
30 files changed
+422
-226
No files matched your search
@@ -1,24 +1,27 @@
|
||||
#ifndef __ZString_h__
|
||||
#define __ZString_h__
|
||||
|
||||
#include "includes"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
namespace coreutils {
|
||||
|
||||
///
|
||||
/// Use the ZString object when advanced parsing algorithms are required to simplify
|
||||
/// parsing. ZString is not a backing store and requires that any referenced buffer
|
||||
/// parsing. ZString is not a backing store and requires that any referenced buffer
|
||||
/// or objects are retained throughout the life of the object. Additionally, ZString
|
||||
/// is non-destructive to its underlying references.
|
||||
///
|
||||
/// ZString provides several methods to reference and parse the content. First method
|
||||
/// is parse(ZString delimiter) which will return a vector of ZString which contains
|
||||
/// is split(ZString delimiter) which will return a vector of ZString which contains
|
||||
/// references to the parts of the string split by the provided delimiter. The delimiter
|
||||
/// portion is omitted from the results.
|
||||
///
|
||||
/// Second method involves a cursor which is a pointer to data contained within the
|
||||
/// Second method involves a cursor which is a pointer to data contained within the
|
||||
/// ZString and is used to point to the current parsing point. Several methods are
|
||||
/// provided to advance through the parsing based upon content and rule checks.
|
||||
/// provided to advance through the parsing based upon content and rule checks.
|
||||
///
|
||||
|
||||
class ZString {
|
||||
@@ -34,9 +37,9 @@ namespace coreutils {
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
|
||||
ZString(const char *data);
|
||||
|
||||
|
||||
///
|
||||
/// Consructor providing the initial setup of the ZString object.
|
||||
///
|
||||
@@ -51,6 +54,12 @@ namespace coreutils {
|
||||
|
||||
ZString(const ZString &zstring);
|
||||
|
||||
///
|
||||
/// Consructor from a string.
|
||||
///
|
||||
|
||||
ZString(std::string string);
|
||||
|
||||
///
|
||||
/// A friend method used to write the value of the ZString from the cursor
|
||||
/// point to an ostream using the << syntax.
|
||||
@@ -60,6 +69,10 @@ namespace coreutils {
|
||||
friend std::ostream& operator<<(std::ostream& os, const std::string& string);
|
||||
friend std::ostream& operator+(std::ostream& os, const ZString& zstring);
|
||||
|
||||
bool operator<(const ZString &valuex) const;
|
||||
bool operator>(const ZString &valuex) const;
|
||||
bool operator==(const ZString &valuex) const;
|
||||
|
||||
///
|
||||
/// Return a vector of ZString objects which contain the parts established
|
||||
/// by using the split method and passing a delimiter value.
|
||||
@@ -101,8 +114,8 @@ namespace coreutils {
|
||||
|
||||
///
|
||||
/// 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
|
||||
/// include string is not encountered in the ZString data.
|
||||
/// of the cursor through the data until a character that is not in the
|
||||
/// include string is not encountered in the ZString data.
|
||||
///
|
||||
|
||||
ZString getTokenInclude(const char *include);
|
||||
@@ -158,6 +171,8 @@ namespace coreutils {
|
||||
|
||||
bool ifNext(const char *value);
|
||||
|
||||
int ifEqualsCount(ZString &comparator);
|
||||
|
||||
///
|
||||
/// Advance the cursor through the ZString for each whitespace character
|
||||
/// encountered.
|
||||
@@ -173,7 +188,7 @@ namespace coreutils {
|
||||
|
||||
///
|
||||
/// Return a block of data as a ZString from the cursor location for
|
||||
/// the number of bytes specified by size.
|
||||
/// the number of bytes specified by size.
|
||||
///
|
||||
|
||||
ZString readBlock(size_t size);
|
||||
@@ -182,29 +197,47 @@ namespace coreutils {
|
||||
/// Return a pointer to the beginning of the ZString data.
|
||||
///
|
||||
|
||||
char* getData();
|
||||
char* getData();
|
||||
|
||||
///
|
||||
/// Return the length of the ZString.
|
||||
/// Return the length of the ZString.
|
||||
///
|
||||
|
||||
size_t getLength();
|
||||
|
||||
|
||||
///
|
||||
/// Set this ZString to have the same data space as the ZString pointer
|
||||
/// passed into the method.
|
||||
///
|
||||
|
||||
|
||||
void setZString(ZString zstring);
|
||||
|
||||
size_t length;
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
void reset();
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
char charAt(int index);
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
bool ifCRLF();
|
||||
|
||||
private:
|
||||
char *data;
|
||||
// size_t length;
|
||||
size_t length;
|
||||
char *cursor;
|
||||
std::vector<ZString> list;
|
||||
|
||||
bool isCharacter(char ch, const char *string);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user