Rework stdext classes

Implement new classes:
* stdext::any => ligher replacement for boost::any
* stdext::packed_any => like any but optimized to use less memory
* stdext::shared_object => ligher replacement for std::shared_ptr
* stdext::shared_object_ptr => replacement for boost::intrusive_ptr
* stdext::fast_storage => for storing dynamic data
* stdext::packed_storage => same but with less memory
* stdext::packed_vector => std::vector with less memory

Compiling should be a little faster now because global boost including
is not needed anymore
This commit is contained in:
Eduardo Bart
2012-08-01 04:49:09 -03:00
parent 1dc7dc0cfc
commit 3bac3dcbb4
92 changed files with 1885 additions and 1208 deletions

View File

@@ -30,8 +30,8 @@ class OTMLDocument;
class OTMLParser;
class OTMLEmitter;
typedef boost::intrusive_ptr<OTMLNode> OTMLNodePtr;
typedef boost::intrusive_ptr<OTMLDocument> OTMLDocumentPtr;
typedef stdext::shared_object_ptr<OTMLNode> OTMLNodePtr;
typedef stdext::shared_object_ptr<OTMLDocument> OTMLDocumentPtr;
typedef std::vector<OTMLNodePtr> OTMLNodeList;
#endif

View File

@@ -84,7 +84,7 @@ OTMLNodePtr OTMLNode::at(const std::string& childTag)
OTMLNodePtr OTMLNode::atIndex(int childIndex)
{
if(childIndex >= size() || childIndex < 0)
throw OTMLException(asOTMLNode(), stdext::mkstr("child node with index '%d' not found", childIndex));
throw OTMLException(asOTMLNode(), stdext::format("child node with index '%d' not found", childIndex));
return m_children[childIndex];
}

View File

@@ -89,7 +89,7 @@ public:
virtual std::string emit();
OTMLNodePtr asOTMLNode() { return self_cast<OTMLNode>(); }
OTMLNodePtr asOTMLNode() { return static_self_cast<OTMLNode>(); }
protected:
OTMLNode() : m_unique(false), m_null(false) { }
@@ -107,13 +107,13 @@ protected:
template<>
inline std::string OTMLNode::value<std::string>() {
std::string value = m_value;
if(boost::starts_with(value, "\"") && boost::ends_with(value, "\"")) {
if(stdext::starts_with(value, "\"") && stdext::ends_with(value, "\"")) {
value = value.substr(1, value.length()-2);
boost::replace_all(value, "\\\\", "\\");
boost::replace_all(value, "\\\"", "\"");
boost::replace_all(value, "\\t", "\t");
boost::replace_all(value, "\\n", "\n");
boost::replace_all(value, "\\'", "\'");
stdext::replace_all(value, "\\\\", "\\");
stdext::replace_all(value, "\\\"", "\"");
stdext::replace_all(value, "\\t", "\t");
stdext::replace_all(value, "\\n", "\n");
stdext::replace_all(value, "\\'", "\'");
}
return value;
}

View File

@@ -80,14 +80,14 @@ void OTMLParser::parseLine(std::string line)
return;
// remove line sides spaces
boost::trim(line);
stdext::trim(line);
// skip empty lines
if(line.empty())
return;
// skip comments
if(boost::starts_with(line, "//"))
if(stdext::starts_with(line, "//"))
return;
// a depth above, change current parent to the previous added node
@@ -119,7 +119,7 @@ void OTMLParser::parseNode(const std::string& data)
// node that has no tag and may have a value
if(!data.empty() && data[0] == '-') {
value = data.substr(1);
boost::trim(value);
stdext::trim(value);
// node that has tag and possible a value
} else if(dotsPos != std::string::npos) {
tag = data.substr(0, dotsPos);
@@ -130,8 +130,8 @@ void OTMLParser::parseNode(const std::string& data)
tag = data;
}
boost::trim(tag);
boost::trim(value);
stdext::trim(tag);
stdext::trim(value);
// process multitine values
if(value == "|" || value == "|-" || value == "|+") {
@@ -148,7 +148,7 @@ void OTMLParser::parseNode(const std::string& data)
// it has contents below the current depth
} else {
// if not empty, its a node
boost::trim(line);
stdext::trim(line);
if(!line.empty()) {
// rewind and break
in.seekg(lastPos, std::ios::beg);
@@ -188,11 +188,13 @@ void OTMLParser::parseNode(const std::string& data)
if(value == "~")
node->setNull(true);
else {
if(boost::starts_with(value, "[") && boost::ends_with(value, "]")) {
if(stdext::starts_with(value, "[") && stdext::ends_with(value, "]")) {
std::string tmp = value.substr(1, value.length()-2);
boost::tokenizer<boost::escaped_list_separator<char>> tokens(tmp);
for(std::string v : tokens)
node->writeIn(stdext::trim(v));
for(std::string v : tokens) {
stdext::trim(v);
node->writeIn(v);
}
} else
node->setValue(value);
}