I'm wondering if you guys can help me start this out. I have a function that is defined as follows:
bool HtmlProcessor::_hasNextAttribute(std::string::iterator & it1, const std::string::iterator & it2, const std::pair<std::string, std::string> attrHolder)
{
/* Parses the first HTML attributes in the iterator range [it1, it2), adding them to attrHolder; eg.
"class="myClass1 myClass2" id="myId" onsubmit = "myFunction()""
---------- _hasNextAttribute -------->
attrHolder = ("class", "myClass1 myClass2")
When the function terminates, it1 will be the iterator to the last character parsed, will be equal to
it2 if no characters were parsed.
*/
}
In other words, it looks for the first pattern of
[someString][possibleWhiteSpace]=[possibleWhiteSpace][quotationMark][someOtherString][quotationMark]
and puts that in a pair (someString, someOtherString)
.
What sort of algorithm should I be using to do this elegantly?
Bonus question:
Where I use the function,
while (_hasNextAttribute(it1, it2, thisAttribute))
I am getting a compiler error
Non-const lvalue reference to type '__wrap_iter<pointer>' cannot bind to a value of unrelated type '__wrap_iter<const_pointer>'
Any idea why that might be?