aBuTaMuHo3 / oop

added lab 5
0 stars 0 forks source link

Замечания по HTML Decode #4

Open alexey-malov opened 7 years ago

alexey-malov commented 7 years ago
1>c:\teaching\2016\new\borisov\oop\lab2\htmldecode\html_decode\html_decode.cpp(45): warning C4018: '<': signed/unsigned mismatch
alexey-malov commented 7 years ago

Не выполнено требование задания:

Для тестирования разрабатываемых функций должны быть разработаны тесты, проверяющие корректность их работы на некотором разумном наборе входных параметров.

alexey-malov commented 7 years ago
    for (int i = 0; i< stringLength;++i)
    {
alexey-malov commented 7 years ago
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;
}

https://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

alexey-malov commented 7 years ago
newString = newString + html.substr(substrStart, substrEnd - substrStart + 1);
...
newString = newString + html.substr(substrStart, substrEnd - substrStart + 1);