Modified ifNext to only take the ZString parameter and let C++ do the conversions.

This commit is contained in:
Brad Arant 2024-10-30 08:36:30 -07:00
parent d0239074a4
commit 3eb1f5954a
4 changed files with 15 additions and 20 deletions

View File

@ -9,15 +9,11 @@
namespace coreutils {
// File::File(std::string fileName, int mode, int authority) {
// open(fileName, mode, authority);
// }
File::File(coreutils::ZString fileName, int mode, int authority) {
open(fileName.str(), mode, authority);
open(fileName, mode, authority);
}
void File::open(std::string fileName, int mode, int authority) {
void File::open(coreutils::ZString fileName, int mode, int authority) {
this->fileName = fileName;

5
File.h
View File

@ -16,7 +16,6 @@ namespace coreutils {
class File {
public:
// File(std::string fileName, int mode, int authority);
File(ZString fileName, int mode = O_RDONLY, int authority = 0664);
~File();
void setBufferSize(size_t size);
@ -30,10 +29,10 @@ namespace coreutils {
size_t size;
bool eof();
std::string fileName;
coreutils::ZString fileName;
private:
void open(std::string fileName, int mode, int authority);
void open(coreutils::ZString fileName, int mode, int authority);
int fd;
coreutils::ZString zstring;
bool mEof = false;

View File

@ -377,16 +377,16 @@ namespace coreutils {
return string == std::string(data, length);
}
bool ZString::ifNext(const char *value) {
if (((data + length) - cursor) < strlen(value))
return false;
bool test = (strncmp(cursor, value, strlen(value)) == 0);
if (test)
cursor += strlen(value);
return test;
}
// bool ZString::ifNext(const char *value) {
// if (((data + length) - cursor) < strlen(value)/)
// return false;
// bool test = (strncmp(cursor, value, strlen(value)) == 0);
// if (test)
// cursor += strlen(value);
// return test;
// }
bool ZString::ifNext(ZString &value) {
bool ZString::ifNext(ZString value) {
if (((data + length) - cursor) < value.getLength())
return false;
bool test = (strncmp(cursor, value.getCursor(), value.getLength()) == 0);

View File

@ -289,13 +289,13 @@ namespace coreutils {
/// the cursor position is equal to the value provided.
///
bool ifNext(const char *value);
// bool ifNext(const char *value);
///
///
///
bool ifNext(ZString &value);
bool ifNext(ZString value);
///
///