Modified ifNext to only take the ZString parameter and let C++ do the conversions.
This commit is contained in:
parent
d0239074a4
commit
3eb1f5954a
8
File.cpp
8
File.cpp
@ -9,15 +9,11 @@
|
|||||||
|
|
||||||
namespace coreutils {
|
namespace coreutils {
|
||||||
|
|
||||||
// File::File(std::string fileName, int mode, int authority) {
|
|
||||||
// open(fileName, mode, authority);
|
|
||||||
// }
|
|
||||||
|
|
||||||
File::File(coreutils::ZString fileName, int mode, int 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;
|
this->fileName = fileName;
|
||||||
|
|
||||||
|
5
File.h
5
File.h
@ -16,7 +16,6 @@ namespace coreutils {
|
|||||||
class File {
|
class File {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// File(std::string fileName, int mode, int authority);
|
|
||||||
File(ZString fileName, int mode = O_RDONLY, int authority = 0664);
|
File(ZString fileName, int mode = O_RDONLY, int authority = 0664);
|
||||||
~File();
|
~File();
|
||||||
void setBufferSize(size_t size);
|
void setBufferSize(size_t size);
|
||||||
@ -30,10 +29,10 @@ namespace coreutils {
|
|||||||
size_t size;
|
size_t size;
|
||||||
bool eof();
|
bool eof();
|
||||||
|
|
||||||
std::string fileName;
|
coreutils::ZString fileName;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void open(std::string fileName, int mode, int authority);
|
void open(coreutils::ZString fileName, int mode, int authority);
|
||||||
int fd;
|
int fd;
|
||||||
coreutils::ZString zstring;
|
coreutils::ZString zstring;
|
||||||
bool mEof = false;
|
bool mEof = false;
|
||||||
|
18
ZString.cpp
18
ZString.cpp
@ -377,16 +377,16 @@ namespace coreutils {
|
|||||||
return string == std::string(data, length);
|
return string == std::string(data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZString::ifNext(const char *value) {
|
// bool ZString::ifNext(const char *value) {
|
||||||
if (((data + length) - cursor) < strlen(value))
|
// if (((data + length) - cursor) < strlen(value)/)
|
||||||
return false;
|
// return false;
|
||||||
bool test = (strncmp(cursor, value, strlen(value)) == 0);
|
// bool test = (strncmp(cursor, value, strlen(value)) == 0);
|
||||||
if (test)
|
// if (test)
|
||||||
cursor += strlen(value);
|
// cursor += strlen(value);
|
||||||
return test;
|
// return test;
|
||||||
}
|
// }
|
||||||
|
|
||||||
bool ZString::ifNext(ZString &value) {
|
bool ZString::ifNext(ZString value) {
|
||||||
if (((data + length) - cursor) < value.getLength())
|
if (((data + length) - cursor) < value.getLength())
|
||||||
return false;
|
return false;
|
||||||
bool test = (strncmp(cursor, value.getCursor(), value.getLength()) == 0);
|
bool test = (strncmp(cursor, value.getCursor(), value.getLength()) == 0);
|
||||||
|
@ -289,13 +289,13 @@ namespace coreutils {
|
|||||||
/// the cursor position is equal to the value provided.
|
/// 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);
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user