Loading isis/src/base/objs/PvlToken/PvlToken.cpp +19 −15 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ namespace Isis { * * @param k Value of the keyword */ PvlToken::PvlToken(const QString &k) { PvlToken::PvlToken(const std::string k) { setKey(k); valueClear(); } Loading @@ -35,28 +35,30 @@ namespace Isis { /** * Set the token keyword. * * @param k IString to load into the token keyword * @param k std::string to load into the token keyword */ void PvlToken::setKey(const QString &k) { void PvlToken::setKey(const std::string k) { m_key = k; }; /** * Returns the token keyword * * @return QString * @return std::string */ QString PvlToken::key() const { std::string PvlToken::key() const { return m_key; }; /** * Returns the token keyword in all uppercase characters * * @return QString * @return std::string */ QString PvlToken::keyUpper() const { return m_key.toUpper(); std::string PvlToken::keyUpper() const { std::string keyUpper(m_key); std::transform(keyUpper.begin(), keyUpper.end(), keyUpper.begin(), ::toupper); return keyUpper; } //! Removes all elements from the value-vector Loading @@ -79,7 +81,7 @@ namespace Isis { * * @param v IString add to the value-vector list */ void PvlToken::addValue(const QString &v) { void PvlToken::addValue(const std::string v) { m_value.push_back(v); } Loading @@ -88,11 +90,11 @@ namespace Isis { * * @param index Zero-based index of vector element to return. Defaults to 0 * * @return QString * @return std::string * * @throws Isis::IException::Programmer */ QString PvlToken::value(const int index) const { std::string PvlToken::value(const int index) const { if((index < 0) || (index >= (int) m_value.size())) { std::string message = Isis::Message::ArraySubscriptNotInRange(index); throw IException(IException::Programmer, message, _FILEINFO_); Loading @@ -105,16 +107,18 @@ namespace Isis { * * @param index Zero-based index of vector element to return. Defaults to 0 * * @return QString * @return std::string * * @throws Isis::IException::Programmer */ QString PvlToken::valueUpper(int index) const { std::string PvlToken::valueUpper(int index) const { if((index < 0) || (index >= (int) m_value.size())) { std::string message = Isis::Message::ArraySubscriptNotInRange(index); throw IException(IException::Programmer, message, _FILEINFO_); } return m_value[index].toUpper(); std::string valueUpper(m_value[index]); std::transform(valueUpper.begin(), valueUpper.end(), valueUpper.begin(), ::toupper); return valueUpper; } } // end namespace isis isis/src/base/objs/PvlToken/PvlToken.h +10 −10 Original line number Diff line number Diff line Loading @@ -37,27 +37,27 @@ namespace Isis { class PvlToken { private: QString m_key; //!< Storage for the keyword name std::vector<QString> m_value; /**<Vector storage for a list of values. std::string m_key; //!< Storage for the keyword name std::vector<std::string> m_value; /**<Vector storage for a list of values. See the standard template library for more information on vectors.*/ public: PvlToken(const QString &k); PvlToken(const std::string k); PvlToken(); ~PvlToken(); void setKey(const QString &k); QString key() const; QString keyUpper() const; void setKey(const std::string k); std::string key() const; std::string keyUpper() const; void addValue(const QString &v); QString value(const int index = 0) const; QString valueUpper(const int index = 0) const; void addValue(const std::string v); std::string value(const int index = 0) const; std::string valueUpper(const int index = 0) const; int valueSize() const; void valueClear(); inline const std::vector<QString> &valueVector() const { inline const std::vector<std::string> &valueVector() const { return m_value; }; }; Loading isis/src/base/objs/PvlTokenizer/PvlTokenizer.cpp +66 −49 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ find files of those names at the top level of this repository. **/ #include <sstream> #include <fstream> #include <regex> #include <QDebug> Loading Loading @@ -36,18 +37,19 @@ namespace Isis { /** * Loads the Token list from a stream. The loading will be terminated upon * reaching either 1) end-of-stream, or * 2) a programmer specified terminator QString * 2) a programmer specified terminator std::string * * @param stream The input stream to tokenize * * @param terminator If the tokenizer see's this QString as a token in the input * @param terminator If the tokenizer see's this std::string as a token in the input * stream it will cease tokenizing. Defaults to "END" * * @throws Isis::iException::Parse */ void PvlTokenizer::Load(std::istream &stream, const QString &terminator) { QString upTerminator(terminator.toUpper()); QString s; void PvlTokenizer::Load(std::istream &stream, const std::string terminator) { std::string upTerminator(terminator); std::transform(upTerminator.begin(), upTerminator.end(), upTerminator.begin(), ::toupper); std::string s; int c; bool newlineFound = false; Loading Loading @@ -138,7 +140,7 @@ namespace Isis { ParseCommaList(t, s); } catch(IException &e) { std::string message = Isis::Message::KeywordValueBad(t.key().toStdString()); std::string message = Isis::Message::KeywordValueBad(t.key()); throw IException(e, IException::Unknown, message, _FILEINFO_); } tokens.push_back(t); Loading @@ -152,7 +154,7 @@ namespace Isis { ParseCommaList(t, s); } catch(IException &e) { std::string message = Isis::Message::KeywordValueBad(t.key().toStdString()); std::string message = Isis::Message::KeywordValueBad(t.key()); throw IException(e, IException::Unknown, message, _FILEINFO_); } tokens.push_back(t); Loading @@ -165,7 +167,7 @@ namespace Isis { s = ReadToDoubleQuote(stream); } catch(IException &e) { std::string message = Isis::Message::KeywordValueBad(t.key().toStdString()); std::string message = Isis::Message::KeywordValueBad(t.key()); throw IException(e, IException::Unknown, message, _FILEINFO_); } t.addValue(s); Loading @@ -179,7 +181,7 @@ namespace Isis { s = ReadToSingleQuote(stream); } catch(IException &e) { std::string message = Isis::Message::KeywordValueBad(t.key().toStdString()); std::string message = Isis::Message::KeywordValueBad(t.key()); throw IException(IException::Unknown, message, _FILEINFO_); } t.addValue(s); Loading @@ -200,10 +202,10 @@ namespace Isis { * * @param stream Input stream to read from * * @return QString * @return std::string */ QString PvlTokenizer::ReadComment(std::istream &stream) { QString s; std::string PvlTokenizer::ReadComment(std::istream &stream) { std::string s; int c; c = stream.get(); Loading @@ -228,10 +230,10 @@ namespace Isis { * * @param stream Input stream to read from * * @return QString * @return std::string */ QString PvlTokenizer::ReadToken(std::istream &stream) { QString s; std::string PvlTokenizer::ReadToken(std::istream &stream) { std::string s; int c; c = stream.get(); Loading Loading @@ -274,15 +276,15 @@ namespace Isis { } QString PvlTokenizer::ReadToDoubleQuote(std::istream &stream) { QString s; std::string PvlTokenizer::ReadToDoubleQuote(std::istream &stream) { std::string s; int c; do { c = stream.get(); ValidateCharacter(c); if(c == EOF) { QString message = Isis::Message::MissingDelimiter('"', s); std::string message = Isis::Message::MissingDelimiter('"', s); throw IException(IException::Unknown, message, _FILEINFO_); } else if(c != '"') { Loading @@ -291,36 +293,43 @@ namespace Isis { } while(c != '"'); int pos = s.indexOf(QRegExp("[\\n\\r]")); std::regex re("[\\n\\r]"); std::smatch sm; std::regex_match(s, sm, re); int pos = sm.position(1); while(pos != -1) { QString first = s.mid(0, pos); std::string first = s.substr(0, pos); bool addspace = false; if(first[pos-1] == ' ') addspace = true; first = first.remove(QRegExp("[\\s]*$")); QString second = s.mid(pos + 1); std::regex e("[\\s]*$"); first = std::regex_replace(first, e, ""); std::string second = s.substr(pos + 1); if(second[0] == ' ') addspace = true; if(second[0] == '\r') addspace = true; if(second[0] == '\n') addspace = true; second = second.remove(QRegExp("^[\\s]*")); e = ("^[\\s]*"); second = std::regex_replace(second, e, ""); if(second[0] == ',') addspace = false; s = first; if(addspace) s += " "; s += second; pos = s.indexOf(QRegExp("[\\n\\r]")); std::regex_match(s, sm, re); pos = sm.position(1); } return s; } QString PvlTokenizer::ReadToSingleQuote(std::istream &stream) { QString s; std::string PvlTokenizer::ReadToSingleQuote(std::istream &stream) { std::string s; int c; do { c = stream.get(); ValidateCharacter(c); if(c == EOF) { QString message = Isis::Message::MissingDelimiter('\'', s); std::string message = Isis::Message::MissingDelimiter('\'', s); throw IException(IException::Unknown, message, _FILEINFO_); } else if(c != '\'') { Loading @@ -329,29 +338,37 @@ namespace Isis { } while(c != '\''); int pos = s.indexOf(QRegExp("[\\n\\r]")); std::regex re("[\\n\\r]"); std::smatch sm; std::regex_match(s, sm, re); int pos = sm.position(1); while(pos != -1) { QString first = s.mid(0, pos); std::string first = s.substr(0, pos); bool addspace = false; if(first[pos-1] == ' ') addspace = true; first = first.remove(QRegExp("[\\s]*$")); QString second = s.mid(pos + 1); std::regex e("[\\s]*$"); first = std::regex_replace(first, e, ""); std::string second = s.substr(pos + 1); if(second[0] == ' ') addspace = true; if(second[0] == '\r') addspace = true; if(second[0] == '\n') addspace = true; second = second.remove(QRegExp("^[\\s]*")); e = ("^[\\s]*"); second = std::regex_replace(second, e, ""); if(second[0] == ',') addspace = false; s = first; if(addspace) s += " "; s += second; pos = s.indexOf(QRegExp("[\\n\\r]")); std::regex_match(s, sm, re); pos = sm.position(1); } return s; } QString PvlTokenizer::ReadToParen(std::istream &stream) { QString s; std::string PvlTokenizer::ReadToParen(std::istream &stream) { std::string s; int c; int leftParenCount = 1; Loading @@ -359,7 +376,7 @@ namespace Isis { c = stream.get(); ValidateCharacter(c); if(c == EOF) { QString message = Isis::Message::MissingDelimiter(')', s); std::string message = Isis::Message::MissingDelimiter(')', s); throw IException(IException::Unknown, message, _FILEINFO_); } else if(c == '"') { Loading @@ -367,7 +384,7 @@ namespace Isis { s += "\"" + ReadToDoubleQuote(stream) + "\""; } catch(IException &) { QString message = Isis::Message::MissingDelimiter('"', s); std::string message = Isis::Message::MissingDelimiter('"', s); throw IException(IException::Unknown, message, _FILEINFO_); } } Loading @@ -376,7 +393,7 @@ namespace Isis { s += "'" + ReadToSingleQuote(stream) + "'"; } catch(IException &) { QString message = Isis::Message::MissingDelimiter('\'', s); std::string message = Isis::Message::MissingDelimiter('\'', s); throw IException(IException::Unknown, message, _FILEINFO_); } } Loading @@ -394,8 +411,8 @@ namespace Isis { return s; } QString PvlTokenizer::ReadToBrace(std::istream &stream) { QString s; std::string PvlTokenizer::ReadToBrace(std::istream &stream) { std::string s; int c; int leftBraceCount = 1; Loading @@ -403,7 +420,7 @@ namespace Isis { c = stream.get(); ValidateCharacter(c); if(c == EOF) { QString message = Isis::Message::MissingDelimiter('}', s); std::string message = Isis::Message::MissingDelimiter('}', s); throw IException(IException::Unknown, message, _FILEINFO_); } else if(c == '"') { Loading @@ -411,7 +428,7 @@ namespace Isis { s += "\"" + ReadToDoubleQuote(stream) + "\""; } catch(IException &e) { QString message = Isis::Message::MissingDelimiter('"', s); std::string message = Isis::Message::MissingDelimiter('"', s); throw IException(IException::Unknown, message, _FILEINFO_); } } Loading @@ -420,7 +437,7 @@ namespace Isis { s += "'" + ReadToSingleQuote(stream) + "'"; } catch(IException &) { QString message = Isis::Message::MissingDelimiter('\'', s); std::string message = Isis::Message::MissingDelimiter('\'', s); throw IException(IException::Unknown, message, _FILEINFO_); } } Loading @@ -439,17 +456,17 @@ namespace Isis { } /** * This routine parses a QString containing a comma separated list. Each of the * This routine parses a std::string containing a comma separated list. Each of the * items in the list is stored as a value in the Token. * * @param t Token to load the comma separated list * * @param cl QString containing comma separated list * @param cl std::string containing comma separated list */ void PvlTokenizer::ParseCommaList(Isis::PvlToken &t, const QString &cl) { stringstream stream(cl.toLatin1().data()); void PvlTokenizer::ParseCommaList(Isis::PvlToken &t, const std::string cl) { stringstream stream(cl); int c; QString s; std::string s; do { SkipWhiteSpace(stream); Loading Loading @@ -499,7 +516,7 @@ namespace Isis { if(isspace(c)) return; if(c == '\0') return; QString message = "ASCII data expected but found unprintable (binary) data"; std::string message = "ASCII data expected but found unprintable (binary) data"; throw IException(IException::Unknown, message, _FILEINFO_); } } // end namespace isis isis/src/base/objs/PvlTokenizer/PvlTokenizer.h +8 −8 Original line number Diff line number Diff line Loading @@ -80,21 +80,21 @@ namespace Isis { the stream*/ QString ReadComment(std::istream &stream); QString ReadToken(std::istream &stream); std::string ReadComment(std::istream &stream); std::string ReadToken(std::istream &stream); bool SkipWhiteSpace(std::istream &stream); QString ReadToSingleQuote(std::istream &stream); QString ReadToDoubleQuote(std::istream &stream); QString ReadToParen(std::istream &stream); QString ReadToBrace(std::istream &stream); void ParseCommaList(Isis::PvlToken &t, const QString &cl); std::string ReadToSingleQuote(std::istream &stream); std::string ReadToDoubleQuote(std::istream &stream); std::string ReadToParen(std::istream &stream); std::string ReadToBrace(std::istream &stream); void ParseCommaList(Isis::PvlToken &t, const std::string cl); void ValidateCharacter(int c); public: PvlTokenizer(); ~PvlTokenizer(); void Load(std::istream &stream, const QString &terminator = "END"); void Load(std::istream &stream, const std::string terminator = "END"); void Clear(); std::vector<Isis::PvlToken> & GetTokenList(); Loading isis/src/core/include/Message.h +2 −2 Original line number Diff line number Diff line Loading @@ -188,7 +188,7 @@ namespace Isis { * @return QString - A standardized Isis error message with the parameter * inserted */ QString MissingDelimiter(const char delimiter); std::string MissingDelimiter(const char delimiter); /** * This error should be used when a delimiter is missing. Loading @@ -199,7 +199,7 @@ namespace Isis { * @return QString - A standardized Isis error message with the parameter * inserted */ QString MissingDelimiter(const char delimiter, const QString &near); std::string MissingDelimiter(const char delimiter, const std::string near); /** * This error should be used when a file could not be opened. Loading Loading
isis/src/base/objs/PvlToken/PvlToken.cpp +19 −15 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ namespace Isis { * * @param k Value of the keyword */ PvlToken::PvlToken(const QString &k) { PvlToken::PvlToken(const std::string k) { setKey(k); valueClear(); } Loading @@ -35,28 +35,30 @@ namespace Isis { /** * Set the token keyword. * * @param k IString to load into the token keyword * @param k std::string to load into the token keyword */ void PvlToken::setKey(const QString &k) { void PvlToken::setKey(const std::string k) { m_key = k; }; /** * Returns the token keyword * * @return QString * @return std::string */ QString PvlToken::key() const { std::string PvlToken::key() const { return m_key; }; /** * Returns the token keyword in all uppercase characters * * @return QString * @return std::string */ QString PvlToken::keyUpper() const { return m_key.toUpper(); std::string PvlToken::keyUpper() const { std::string keyUpper(m_key); std::transform(keyUpper.begin(), keyUpper.end(), keyUpper.begin(), ::toupper); return keyUpper; } //! Removes all elements from the value-vector Loading @@ -79,7 +81,7 @@ namespace Isis { * * @param v IString add to the value-vector list */ void PvlToken::addValue(const QString &v) { void PvlToken::addValue(const std::string v) { m_value.push_back(v); } Loading @@ -88,11 +90,11 @@ namespace Isis { * * @param index Zero-based index of vector element to return. Defaults to 0 * * @return QString * @return std::string * * @throws Isis::IException::Programmer */ QString PvlToken::value(const int index) const { std::string PvlToken::value(const int index) const { if((index < 0) || (index >= (int) m_value.size())) { std::string message = Isis::Message::ArraySubscriptNotInRange(index); throw IException(IException::Programmer, message, _FILEINFO_); Loading @@ -105,16 +107,18 @@ namespace Isis { * * @param index Zero-based index of vector element to return. Defaults to 0 * * @return QString * @return std::string * * @throws Isis::IException::Programmer */ QString PvlToken::valueUpper(int index) const { std::string PvlToken::valueUpper(int index) const { if((index < 0) || (index >= (int) m_value.size())) { std::string message = Isis::Message::ArraySubscriptNotInRange(index); throw IException(IException::Programmer, message, _FILEINFO_); } return m_value[index].toUpper(); std::string valueUpper(m_value[index]); std::transform(valueUpper.begin(), valueUpper.end(), valueUpper.begin(), ::toupper); return valueUpper; } } // end namespace isis
isis/src/base/objs/PvlToken/PvlToken.h +10 −10 Original line number Diff line number Diff line Loading @@ -37,27 +37,27 @@ namespace Isis { class PvlToken { private: QString m_key; //!< Storage for the keyword name std::vector<QString> m_value; /**<Vector storage for a list of values. std::string m_key; //!< Storage for the keyword name std::vector<std::string> m_value; /**<Vector storage for a list of values. See the standard template library for more information on vectors.*/ public: PvlToken(const QString &k); PvlToken(const std::string k); PvlToken(); ~PvlToken(); void setKey(const QString &k); QString key() const; QString keyUpper() const; void setKey(const std::string k); std::string key() const; std::string keyUpper() const; void addValue(const QString &v); QString value(const int index = 0) const; QString valueUpper(const int index = 0) const; void addValue(const std::string v); std::string value(const int index = 0) const; std::string valueUpper(const int index = 0) const; int valueSize() const; void valueClear(); inline const std::vector<QString> &valueVector() const { inline const std::vector<std::string> &valueVector() const { return m_value; }; }; Loading
isis/src/base/objs/PvlTokenizer/PvlTokenizer.cpp +66 −49 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ find files of those names at the top level of this repository. **/ #include <sstream> #include <fstream> #include <regex> #include <QDebug> Loading Loading @@ -36,18 +37,19 @@ namespace Isis { /** * Loads the Token list from a stream. The loading will be terminated upon * reaching either 1) end-of-stream, or * 2) a programmer specified terminator QString * 2) a programmer specified terminator std::string * * @param stream The input stream to tokenize * * @param terminator If the tokenizer see's this QString as a token in the input * @param terminator If the tokenizer see's this std::string as a token in the input * stream it will cease tokenizing. Defaults to "END" * * @throws Isis::iException::Parse */ void PvlTokenizer::Load(std::istream &stream, const QString &terminator) { QString upTerminator(terminator.toUpper()); QString s; void PvlTokenizer::Load(std::istream &stream, const std::string terminator) { std::string upTerminator(terminator); std::transform(upTerminator.begin(), upTerminator.end(), upTerminator.begin(), ::toupper); std::string s; int c; bool newlineFound = false; Loading Loading @@ -138,7 +140,7 @@ namespace Isis { ParseCommaList(t, s); } catch(IException &e) { std::string message = Isis::Message::KeywordValueBad(t.key().toStdString()); std::string message = Isis::Message::KeywordValueBad(t.key()); throw IException(e, IException::Unknown, message, _FILEINFO_); } tokens.push_back(t); Loading @@ -152,7 +154,7 @@ namespace Isis { ParseCommaList(t, s); } catch(IException &e) { std::string message = Isis::Message::KeywordValueBad(t.key().toStdString()); std::string message = Isis::Message::KeywordValueBad(t.key()); throw IException(e, IException::Unknown, message, _FILEINFO_); } tokens.push_back(t); Loading @@ -165,7 +167,7 @@ namespace Isis { s = ReadToDoubleQuote(stream); } catch(IException &e) { std::string message = Isis::Message::KeywordValueBad(t.key().toStdString()); std::string message = Isis::Message::KeywordValueBad(t.key()); throw IException(e, IException::Unknown, message, _FILEINFO_); } t.addValue(s); Loading @@ -179,7 +181,7 @@ namespace Isis { s = ReadToSingleQuote(stream); } catch(IException &e) { std::string message = Isis::Message::KeywordValueBad(t.key().toStdString()); std::string message = Isis::Message::KeywordValueBad(t.key()); throw IException(IException::Unknown, message, _FILEINFO_); } t.addValue(s); Loading @@ -200,10 +202,10 @@ namespace Isis { * * @param stream Input stream to read from * * @return QString * @return std::string */ QString PvlTokenizer::ReadComment(std::istream &stream) { QString s; std::string PvlTokenizer::ReadComment(std::istream &stream) { std::string s; int c; c = stream.get(); Loading @@ -228,10 +230,10 @@ namespace Isis { * * @param stream Input stream to read from * * @return QString * @return std::string */ QString PvlTokenizer::ReadToken(std::istream &stream) { QString s; std::string PvlTokenizer::ReadToken(std::istream &stream) { std::string s; int c; c = stream.get(); Loading Loading @@ -274,15 +276,15 @@ namespace Isis { } QString PvlTokenizer::ReadToDoubleQuote(std::istream &stream) { QString s; std::string PvlTokenizer::ReadToDoubleQuote(std::istream &stream) { std::string s; int c; do { c = stream.get(); ValidateCharacter(c); if(c == EOF) { QString message = Isis::Message::MissingDelimiter('"', s); std::string message = Isis::Message::MissingDelimiter('"', s); throw IException(IException::Unknown, message, _FILEINFO_); } else if(c != '"') { Loading @@ -291,36 +293,43 @@ namespace Isis { } while(c != '"'); int pos = s.indexOf(QRegExp("[\\n\\r]")); std::regex re("[\\n\\r]"); std::smatch sm; std::regex_match(s, sm, re); int pos = sm.position(1); while(pos != -1) { QString first = s.mid(0, pos); std::string first = s.substr(0, pos); bool addspace = false; if(first[pos-1] == ' ') addspace = true; first = first.remove(QRegExp("[\\s]*$")); QString second = s.mid(pos + 1); std::regex e("[\\s]*$"); first = std::regex_replace(first, e, ""); std::string second = s.substr(pos + 1); if(second[0] == ' ') addspace = true; if(second[0] == '\r') addspace = true; if(second[0] == '\n') addspace = true; second = second.remove(QRegExp("^[\\s]*")); e = ("^[\\s]*"); second = std::regex_replace(second, e, ""); if(second[0] == ',') addspace = false; s = first; if(addspace) s += " "; s += second; pos = s.indexOf(QRegExp("[\\n\\r]")); std::regex_match(s, sm, re); pos = sm.position(1); } return s; } QString PvlTokenizer::ReadToSingleQuote(std::istream &stream) { QString s; std::string PvlTokenizer::ReadToSingleQuote(std::istream &stream) { std::string s; int c; do { c = stream.get(); ValidateCharacter(c); if(c == EOF) { QString message = Isis::Message::MissingDelimiter('\'', s); std::string message = Isis::Message::MissingDelimiter('\'', s); throw IException(IException::Unknown, message, _FILEINFO_); } else if(c != '\'') { Loading @@ -329,29 +338,37 @@ namespace Isis { } while(c != '\''); int pos = s.indexOf(QRegExp("[\\n\\r]")); std::regex re("[\\n\\r]"); std::smatch sm; std::regex_match(s, sm, re); int pos = sm.position(1); while(pos != -1) { QString first = s.mid(0, pos); std::string first = s.substr(0, pos); bool addspace = false; if(first[pos-1] == ' ') addspace = true; first = first.remove(QRegExp("[\\s]*$")); QString second = s.mid(pos + 1); std::regex e("[\\s]*$"); first = std::regex_replace(first, e, ""); std::string second = s.substr(pos + 1); if(second[0] == ' ') addspace = true; if(second[0] == '\r') addspace = true; if(second[0] == '\n') addspace = true; second = second.remove(QRegExp("^[\\s]*")); e = ("^[\\s]*"); second = std::regex_replace(second, e, ""); if(second[0] == ',') addspace = false; s = first; if(addspace) s += " "; s += second; pos = s.indexOf(QRegExp("[\\n\\r]")); std::regex_match(s, sm, re); pos = sm.position(1); } return s; } QString PvlTokenizer::ReadToParen(std::istream &stream) { QString s; std::string PvlTokenizer::ReadToParen(std::istream &stream) { std::string s; int c; int leftParenCount = 1; Loading @@ -359,7 +376,7 @@ namespace Isis { c = stream.get(); ValidateCharacter(c); if(c == EOF) { QString message = Isis::Message::MissingDelimiter(')', s); std::string message = Isis::Message::MissingDelimiter(')', s); throw IException(IException::Unknown, message, _FILEINFO_); } else if(c == '"') { Loading @@ -367,7 +384,7 @@ namespace Isis { s += "\"" + ReadToDoubleQuote(stream) + "\""; } catch(IException &) { QString message = Isis::Message::MissingDelimiter('"', s); std::string message = Isis::Message::MissingDelimiter('"', s); throw IException(IException::Unknown, message, _FILEINFO_); } } Loading @@ -376,7 +393,7 @@ namespace Isis { s += "'" + ReadToSingleQuote(stream) + "'"; } catch(IException &) { QString message = Isis::Message::MissingDelimiter('\'', s); std::string message = Isis::Message::MissingDelimiter('\'', s); throw IException(IException::Unknown, message, _FILEINFO_); } } Loading @@ -394,8 +411,8 @@ namespace Isis { return s; } QString PvlTokenizer::ReadToBrace(std::istream &stream) { QString s; std::string PvlTokenizer::ReadToBrace(std::istream &stream) { std::string s; int c; int leftBraceCount = 1; Loading @@ -403,7 +420,7 @@ namespace Isis { c = stream.get(); ValidateCharacter(c); if(c == EOF) { QString message = Isis::Message::MissingDelimiter('}', s); std::string message = Isis::Message::MissingDelimiter('}', s); throw IException(IException::Unknown, message, _FILEINFO_); } else if(c == '"') { Loading @@ -411,7 +428,7 @@ namespace Isis { s += "\"" + ReadToDoubleQuote(stream) + "\""; } catch(IException &e) { QString message = Isis::Message::MissingDelimiter('"', s); std::string message = Isis::Message::MissingDelimiter('"', s); throw IException(IException::Unknown, message, _FILEINFO_); } } Loading @@ -420,7 +437,7 @@ namespace Isis { s += "'" + ReadToSingleQuote(stream) + "'"; } catch(IException &) { QString message = Isis::Message::MissingDelimiter('\'', s); std::string message = Isis::Message::MissingDelimiter('\'', s); throw IException(IException::Unknown, message, _FILEINFO_); } } Loading @@ -439,17 +456,17 @@ namespace Isis { } /** * This routine parses a QString containing a comma separated list. Each of the * This routine parses a std::string containing a comma separated list. Each of the * items in the list is stored as a value in the Token. * * @param t Token to load the comma separated list * * @param cl QString containing comma separated list * @param cl std::string containing comma separated list */ void PvlTokenizer::ParseCommaList(Isis::PvlToken &t, const QString &cl) { stringstream stream(cl.toLatin1().data()); void PvlTokenizer::ParseCommaList(Isis::PvlToken &t, const std::string cl) { stringstream stream(cl); int c; QString s; std::string s; do { SkipWhiteSpace(stream); Loading Loading @@ -499,7 +516,7 @@ namespace Isis { if(isspace(c)) return; if(c == '\0') return; QString message = "ASCII data expected but found unprintable (binary) data"; std::string message = "ASCII data expected but found unprintable (binary) data"; throw IException(IException::Unknown, message, _FILEINFO_); } } // end namespace isis
isis/src/base/objs/PvlTokenizer/PvlTokenizer.h +8 −8 Original line number Diff line number Diff line Loading @@ -80,21 +80,21 @@ namespace Isis { the stream*/ QString ReadComment(std::istream &stream); QString ReadToken(std::istream &stream); std::string ReadComment(std::istream &stream); std::string ReadToken(std::istream &stream); bool SkipWhiteSpace(std::istream &stream); QString ReadToSingleQuote(std::istream &stream); QString ReadToDoubleQuote(std::istream &stream); QString ReadToParen(std::istream &stream); QString ReadToBrace(std::istream &stream); void ParseCommaList(Isis::PvlToken &t, const QString &cl); std::string ReadToSingleQuote(std::istream &stream); std::string ReadToDoubleQuote(std::istream &stream); std::string ReadToParen(std::istream &stream); std::string ReadToBrace(std::istream &stream); void ParseCommaList(Isis::PvlToken &t, const std::string cl); void ValidateCharacter(int c); public: PvlTokenizer(); ~PvlTokenizer(); void Load(std::istream &stream, const QString &terminator = "END"); void Load(std::istream &stream, const std::string terminator = "END"); void Clear(); std::vector<Isis::PvlToken> & GetTokenList(); Loading
isis/src/core/include/Message.h +2 −2 Original line number Diff line number Diff line Loading @@ -188,7 +188,7 @@ namespace Isis { * @return QString - A standardized Isis error message with the parameter * inserted */ QString MissingDelimiter(const char delimiter); std::string MissingDelimiter(const char delimiter); /** * This error should be used when a delimiter is missing. Loading @@ -199,7 +199,7 @@ namespace Isis { * @return QString - A standardized Isis error message with the parameter * inserted */ QString MissingDelimiter(const char delimiter, const QString &near); std::string MissingDelimiter(const char delimiter, const std::string near); /** * This error should be used when a file could not be opened. Loading