Open alexey-malov opened 7 years ago
Не выполнено требование задания:
Для тестирования разрабатываемых функций должны быть разработаны тесты, проверяющие корректность их работы на некотором разумном наборе входных параметров.
for (int i = 0; i< stringLength;++i)
{
string HtmlDecode(string const &html)
{
char startSymbol = '&';
char endSymbol = ';';
size_t stringLength = html.length();
string newString, tempString;
char symbol;
bool substringStarted = false;
for (int i = 0; i< stringLength;++i)
{
symbol = html[i];
if (symbol == startSymbol)
{
substringStarted = true;
newString += tempString;
tempString.clear();
}
if (substringStarted)
{
tempString += symbol;
if (symbol == endSymbol)
{
substringStarted = false;
newString += CheckDictionary(tempString);
tempString.clear();
}
}
else
{
newString += symbol;
}
}
newString += tempString;
return newString;
}
&
и ;
во временной строке, ведь они итак хранятся в сканируемой строке. Достаточно хранить их позиции. В string есть метод compare, позволяющий проверять диапазоны строки.
В C++17 появился string_view, хранящий ссылку на диапазон символов строки (VS2017)
https://medium.com/@sshambir/std-string-view-%D0%BA%D0%BE%D0%BD%D1%81%D1%82%D1%80%D1%83%D0%B8%D1%80%D1%83%D0%B5%D1%82%D1%81%D1%8F-%D0%B8%D0%B7-%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%BD%D1%8B%D1%85-%D1%8D%D0%BA%D0%B7%D0%B5%D0%BC%D0%BF%D0%BB%D1%8F%D1%80%D0%BE%D0%B2-%D1%81%D1%82%D1%80%D0%BE%D0%BA-3453e7d3a75bhttps://ps-group.github.io/cxx/cxx17#wow6
В Boost есть string_ref с аналогичным функционалом (VS2015 поддерживается) https://github.com/alexey-malov/oop/blob/master/samples/02-stl-tdd/StringReference/main.cpp
newString = newString + html.substr(substrStart, substrEnd - substrStart + 1);
...
newString = newString + html.substr(substrStart, substrEnd - substrStart + 1);