Update to v093r05 release.

byuu says:

Library concept has been refined as per the general forum discussion.
This commit is contained in:
Tim Allen
2013-12-03 21:01:59 +11:00
parent b4f18c3b47
commit ed4e87f65e
37 changed files with 303 additions and 212 deletions

View File

@@ -81,10 +81,10 @@ public:
inline bool match(rstring) const;
inline bool imatch(rstring) const;
inline bool beginswith(rstring) const;
inline bool ibeginswith(rstring) const;
inline bool endswith(rstring) const;
inline bool iendswith(rstring) const;
inline bool beginsWith(rstring) const;
inline bool ibeginsWith(rstring) const;
inline bool endsWith(rstring) const;
inline bool iendsWith(rstring) const;
inline string slice(unsigned offset, unsigned length = ~0u) const;

View File

@@ -39,11 +39,11 @@ inline string evaluateExpression(Node* node) {
inline int64_t evaluateInteger(Node* node) {
if(node->type == Node::Type::Literal) {
if(node->literal.beginswith("0b")) return nall::binary(node->literal);
if(node->literal.beginswith("0o")) return nall::octal(node->literal);
if(node->literal.beginswith("0x")) return nall::hex(node->literal);
if(node->literal.beginswith("%")) return nall::binary(node->literal);
if(node->literal.beginswith("$")) return nall::hex(node->literal);
if(node->literal.beginsWith("0b")) return nall::binary(node->literal);
if(node->literal.beginsWith("0o")) return nall::octal(node->literal);
if(node->literal.beginsWith("0x")) return nall::hex(node->literal);
if(node->literal.beginsWith("%")) return nall::binary(node->literal);
if(node->literal.beginsWith("$")) return nall::hex(node->literal);
return nall::integer(node->literal);
}

View File

@@ -4,7 +4,7 @@ namespace nall {
namespace Markup {
inline Node Document(const string& markup) {
if(markup.beginswith("<")) return XML::Document(markup);
if(markup.beginsWith("<")) return XML::Document(markup);
return BML::Document(markup);
}

View File

@@ -131,8 +131,8 @@ struct Node {
vector<Node>::iterator begin() { return children.begin(); }
vector<Node>::iterator end() { return children.end(); }
const vector<Node>::const_iterator begin() const { return children.begin(); }
const vector<Node>::const_iterator end() const { return children.end(); }
const vector<Node>::constIterator begin() const { return children.begin(); }
const vector<Node>::constIterator end() const { return children.end(); }
Node() : attribute(false), level(0) {}

View File

@@ -8,7 +8,7 @@ string activepath() {
string result = path;
if(result.empty()) result = ".";
result.transform("\\", "/");
if(result.endswith("/") == false) result.append("/");
if(result.endsWith("/") == false) result.append("/");
return result;
}
@@ -18,7 +18,7 @@ string realpath(const string& name) {
if(::realpath(name, path)) result = path;
if(result.empty()) result = {activepath(), name};
result.transform("\\", "/");
if(result.endswith("/") == false) result.append("/");
if(result.endsWith("/") == false) result.append("/");
return result;
}
@@ -36,7 +36,7 @@ string userpath() {
result = userinfo->pw_dir;
#endif
if(result.empty()) result = ".";
if(result.endswith("/") == false) result.append("/");
if(result.endsWith("/") == false) result.append("/");
return result;
}
@@ -55,7 +55,7 @@ string configpath() {
result = {userpath(), ".config/"};
#endif
if(result.empty()) result = ".";
if(result.endswith("/") == false) result.append("/");
if(result.endsWith("/") == false) result.append("/");
return result;
}
@@ -72,7 +72,7 @@ string sharedpath() {
result = "/usr/share/";
#endif
if(result.empty()) result = ".";
if(result.endswith("/") == false) result.append("/");
if(result.endsWith("/") == false) result.append("/");
return result;
}

View File

@@ -28,22 +28,22 @@ bool string::iequals(rstring source) const {
return icompare(source) == 0;
}
bool string::beginswith(rstring source) const {
bool string::beginsWith(rstring source) const {
if(source.size() > size()) return false;
return memcmp(data(), source.data(), source.size()) == 0;
}
bool string::ibeginswith(rstring source) const {
bool string::ibeginsWith(rstring source) const {
if(source.size() > size()) return false;
return imemcmp(data(), source.data(), source.size()) == 0;
}
bool string::endswith(rstring source) const {
bool string::endsWith(rstring source) const {
if(source.size() > size()) return false;
return memcmp(data() + size() - source.size(), source.data(), source.size()) == 0;
}
bool string::iendswith(rstring source) const {
bool string::iendsWith(rstring source) const {
if(source.size() > size()) return false;
return imemcmp(data() + size() - source.size(), source.data(), source.size()) == 0;
}