std::string
characterstr::getNextCharacterString(const std::string& input_str,
- std::string::const_iterator& input_iterator)
+ std::string::const_iterator& input_iterator,
+ bool* quoted)
{
string result;
isc_throw(InvalidRdataText, "The quotes are not paired");
}
+ if (quoted != NULL) {
+ *quoted = quotes_separated;
+ }
+
return (result);
}
/// \param input_iterator The iterator from which to start extracting,
/// the iterator will be updated to new position after the function
/// is returned
+ /// \param quoted If not \c NULL, returns \c true at this address if
+ /// the string is quoted, \cfalse otherwise
/// \return A std::string that contains the extracted <character-string>
std::string getNextCharacterString(const std::string& input_str,
- std::string::const_iterator& input_iterator);
+ std::string::const_iterator& input_iterator,
+ bool* quoted = NULL);
/// Get a <character-string> from a input buffer
///
public:
CharacterString(const string& str){
string::const_iterator it = str.begin();
- characterStr_ = getNextCharacterString(str, it);
+ characterStr_ = getNextCharacterString(str, it, &is_quoted_);
}
const string& str() const { return characterStr_; }
+ bool quoted() const { return (is_quoted_); }
private:
string characterStr_;
+ bool is_quoted_;
};
TEST(CharacterStringTest, testNormalCase) {
// Test <character-string> that separated by space
CharacterString cstr2("foo bar");
EXPECT_EQ(string("foo"), cstr2.str());
+ EXPECT_FALSE(cstr2.quoted());
// Test <character-string> that separated by quotes
CharacterString cstr3("\"foo bar\"");
EXPECT_EQ(string("foo bar"), cstr3.str());
+ EXPECT_TRUE(cstr3.quoted());
// Test <character-string> that not separate by quotes but ended with quotes
CharacterString cstr4("foo\"");
EXPECT_EQ(string("foo\""), cstr4.str());
+ EXPECT_FALSE(cstr4.quoted());
}
TEST(CharacterStringTest, testBadCase) {