diff options
Diffstat (limited to 'project2/fileRows.cpp')
-rw-r--r-- | project2/fileRows.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/project2/fileRows.cpp b/project2/fileRows.cpp index 78a61a5..4a3c58b 100644 --- a/project2/fileRows.cpp +++ b/project2/fileRows.cpp @@ -20,7 +20,7 @@ FileRows::FileRows(const xmlpp::Element * p) : BOOST_FOREACH(const xmlpp::Node * node, p->find("columns/column")) { const xmlpp::Element * elem = dynamic_cast<const xmlpp::Element *>(node); if (elem) { - columns.push_back(elem->get_child_text()->get_content()); + columns.push_back(boost::shared_ptr<Glib::ustring>(new Glib::ustring(elem->get_child_text()->get_content()))); } } } @@ -49,7 +49,7 @@ FileRows::columnCount() const const Glib::ustring & FileRows::getColumnName(unsigned int col) const { - return columns[col]; + return *columns[col]; } void @@ -68,11 +68,12 @@ FileRows::execute(const RowProcessor * rp) const bool mkCols = columns.empty(); bool inQuotes = false; bool prevWasQuote = false; - Glib::ustring tok; + typedef boost::shared_ptr<Glib::ustring> StringPtr; + StringPtr tok(new Glib::ustring()); BOOST_FOREACH(gunichar c, line) { if (c == quoteChar) { if (prevWasQuote) { - tok += c; + *tok += c; prevWasQuote = false; inQuotes = !inQuotes; } @@ -87,29 +88,29 @@ FileRows::execute(const RowProcessor * rp) const addColumn(tok); } else { - values.push_back(ValPtr(new Glib::ustring(tok))); + values.push_back(tok); curCol++; } - tok.clear(); + tok = StringPtr(new Glib::ustring()); } else { prevWasQuote = false; - tok += c; + *tok += c; } } - if (tok.length()) { + if (tok->length()) { if (mkCols) { addColumn(tok); } else { - values.push_back(ValPtr(new Glib::ustring(tok))); + values.push_back(tok); curCol++; } } if (!mkCols) { if (keepBlankRows || !values.empty()) { while (values.size() < columns.size()) { - values.push_back(ValPtr(new Glib::ustring())); + values.push_back(VariableType()); curCol++; } rp->rowReady(); @@ -146,7 +147,7 @@ FileRows::getCurrentValue(const Glib::ustring & id) const { Values::const_iterator v = values.begin(); for (Columns::const_iterator i = columns.begin(); i != columns.end(); i++, v++) { - if (*i == id) { + if (**i == id) { return *v; } } @@ -154,13 +155,12 @@ FileRows::getCurrentValue(const Glib::ustring & id) const } void -FileRows::addColumn(const Glib::ustring & rawtok) const +FileRows::addColumn(boost::shared_ptr<Glib::ustring> tok) const { - columns.push_back(rawtok); - Glib::ustring & tok(columns.back()); - for (Glib::ustring::iterator i = tok.begin(); i != tok.end(); ) { + columns.push_back(tok); + for (Glib::ustring::iterator i = tok->begin(); i != tok->end(); ) { if (!isalnum(*i)) { - tok.erase(i); + tok->erase(i); } else { i++; |