X-Git-Url: http://Server1/repobrowser/?p=xestiacalendar%2F.git;a=blobdiff_plain;f=source%2Fcommon%2Ftext.cpp;h=4581e385961a9961ff219456940db8bc25584aa1;hp=03eb88d7353e4faf6bbc76c60ff77b6fad59805b;hb=22339c898f8c04af609419f036828323b26f480f;hpb=d4b44cdc2002d9214a0ae2528be8b1cab14c5120 diff --git a/source/common/text.cpp b/source/common/text.cpp index 03eb88d..4581e38 100644 --- a/source/common/text.cpp +++ b/source/common/text.cpp @@ -21,27 +21,27 @@ using namespace std; multimap ProcessTextVectors(vector *TextProperties, - vector *TextValues, - bool SearchMultiple, - string Property){ + vector *textValues, + bool searchMultiple, + string property){ - multimap ProcessResult; + multimap processResult; // Go through each of the values. - int TextSeekCount = 0; - int TextPropertySize = 0; - int PropertySeekCount = 0; - string PropertyName = ""; - int PropertyNameSize = 0; - char BufferChar = 0; + int textSeekCount = 0; + int textPropertySize = 0; + int propertySeekCount = 0; + string propertyName = ""; + int propertyNameSize = 0; + char bufferChar = 0; - for (vector::iterator iter = TextProperties->begin(); - iter != TextProperties->end(); iter++){ + for (vector::iterator iter = textProperties->begin(); + iter != textProperties->end(); iter++){ - TextPropertySize = iter->size(); + textPropertySize = iter->size(); - if (TextPropertySize == 0){ + if (textPropertySize == 0){ // Text property size is 0. Go to the next // pair. @@ -52,28 +52,28 @@ multimap ProcessTextVectors(vector *TextProperties, // Get the property data up to the first semi-colon. - while (TextSeekCount < TextPropertySize){ + while (textSeekCount < textPropertySize){ - BufferChar = (*iter)[TextSeekCount]; + bufferChar = (*iter)[textSeekCount]; - if (BufferChar == ';'){ + if (bufferChar == ';'){ break; } - PropertyName += BufferChar; + PropertyName += bufferChar; - TextSeekCount++; + textSeekCount++; } - if (*iter == Property || PropertyName == Property){ + if (*iter == property || propertyName == property){ - ProcessResult.insert(make_pair((*TextProperties)[PropertySeekCount], - (*TextValues)[PropertySeekCount])); + processResult.insert(make_pair((*textProperties)[propertySeekCount], + (*textValues)[propertySeekCount])); // Check to continue if one is found. - if (SearchMultiple == false){ + if (searchMultiple == false){ // Found one, don't search for anymore. @@ -83,23 +83,23 @@ multimap ProcessTextVectors(vector *TextProperties, } - PropertySeekCount++; - TextPropertySize = 0; - TextSeekCount = 0; - PropertyName.clear(); + propertySeekCount++; + textPropertySize = 0; + textSeekCount = 0; + propertyName.clear(); } - return ProcessResult; + return processResult; } -map SplitValues(string InputData){ +map SplitValues(string inputData){ - map FinalSplitValues; - map SplitPoints; - map SplitLength; - size_t intPropertyLen = InputData.size(); + map finalSplitValues; + map splitPoints; + map splitLength; + size_t intPropertyLen = inputData.size(); int intSplitsFound = 0; int intSplitSize = 0; int intSplitSeek = 0; @@ -111,21 +111,21 @@ map SplitValues(string InputData){ intSplitSize++; - InputData.substr(intPrevSplitFound, intSplitSize); + inputData.substr(intPrevSplitFound, intSplitSize); - if (InputData.substr(i, 1) == ";" && - InputData.substr((i - 1), 1) != "\\"){ + if (inputData.substr(i, 1) == ";" && + inputData.substr((i - 1), 1) != "\\"){ if (intSplitsFound > 0){ // Split the value into two. - PropertyNameValue NVData = SplitNameValue(InputData.substr(intPrevSplitFound, (intSplitSize - 1))); + PropertyNameValue nVData = SplitNameValue(inputData.substr(intPrevSplitFound, (intSplitSize - 1))); - if (FinalSplitValues.find(NVData.Name) != FinalSplitValues.end()){ - FinalSplitValues.insert(make_pair(NVData.Name, NVData.Value)); + if (finalSplitValues.find(nVData.name) != finalSplitValues.end()){ + finalSplitValues.insert(make_pair(nVData.name, nVData.value)); } else { - FinalSplitValues[NVData.Name] = NVData.Value; + finalSplitValues[nVData.name] = nVData.value; } } @@ -140,89 +140,89 @@ map SplitValues(string InputData){ if (intSplitsFound > 0){ - PropertyNameValue NVData = SplitNameValue(InputData.substr(intPrevSplitFound, (intSplitSize - 1))); + PropertyNameValue nVData = SplitNameValue(inputData.substr(intPrevSplitFound, (intSplitSize - 1))); - if (FinalSplitValues.find(NVData.Name) != FinalSplitValues.end()){ - FinalSplitValues.insert(make_pair(NVData.Name, NVData.Value)); + if (finalSplitValues.find(nVData.name) != finalSplitValues.end()){ + finalSplitValues.insert(make_pair(nVData.name, nVData.value)); } else { - FinalSplitValues[NVData.Name] = NVData.Value; + finalSplitValues[nVData.name] = nVData.value; } } - return FinalSplitValues; + return finalSplitValues; } -PropertyNameValue SplitNameValue(string InputData){ +PropertyNameValue SplitNameValue(string inputData){ - PropertyNameValue FinalNameValue; - int InputDataLength = InputData.size(); - int SeekCount = 0; - bool QuoteMode = false; - bool DataFound = false; + PropertyNameValue finalNameValue; + int inputDataLength = inputData.size(); + int seekCount = 0; + bool quoteMode = false; + bool dataFound = false; - while (SeekCount < InputDataLength){ + while (seekCount < inputDataLength){ - if (InputData[SeekCount] == '='){ + if (inputData[seekCount] == '='){ - FinalNameValue.Name = InputData.substr(0, SeekCount); + finalNameValue.name = inputData.substr(0, seekCount); try{ - FinalNameValue.Value = InputData.substr((SeekCount + 1)); + finalNameValue.Value = inputData.substr((seekCount + 1)); } catch (const out_of_range &oor){ // Do nothing. Have an empty final value. } - DataFound = true; + dataFound = true; break; } - SeekCount++; + seekCount++; } - if (DataFound == false){ + if (dataFound == false){ - FinalNameValue.Name = InputData; + finalNameValue.Name = inputData; } // Check if the value has quotes at the start and end. // Remove them if this is the case. - if (FinalNameValue.Value.front() == '\"' && - FinalNameValue.Value.back() == '\"'){ + if (finalNameValue.value.front() == '\"' && + finalNameValue.value.back() == '\"'){ - FinalNameValue.Value.erase(0, 1); - FinalNameValue.Value.erase((FinalNameValue.Value.size() - 1), 1); + finalNameValue.value.erase(0, 1); + finalNameValue.value.erase((finalNameValue.value.size() - 1), 1); } - return FinalNameValue; + return finalNameValue; } -bool HexToInt(std::string *HexString, int *Number){ +bool HexToInt(std::string *hexString, int *number){ // Check that each character in the string is a number // or a letter (a-f/A-F). - char Char = 0; - int CharNum = 0; + char charLetter = 0; + int charNum = 0; - for (int CharSeek = 0; - CharSeek < HexString->size(); CharSeek++){ + for (int charSeek = 0; + charSeek < hexString->size(); charSeek++){ // Check if character is a number (0-9). - Char = HexString->at(CharSeek); - CharNum = Char; + charLetter = hexString->at(charSeek); + charNum = charLetter; - if (CharNum >= 48 && - CharNum <= 57){ + if (charNum >= 48 && + charNum <= 57){ continue; @@ -230,8 +230,8 @@ bool HexToInt(std::string *HexString, int *Number){ // Check if character is a letter (A-F) - if (CharNum >= 65 && - CharNum <= 70){ + if (charNum >= 65 && + charNum <= 70){ continue; @@ -239,8 +239,8 @@ bool HexToInt(std::string *HexString, int *Number){ // Check if character is a letter (a-f). - if (CharNum >= 97 && - CharNum <= 102){ + if (charNum >= 97 && + charNum <= 102){ continue; @@ -256,7 +256,7 @@ bool HexToInt(std::string *HexString, int *Number){ try { - *Number = stoi((*HexString), nullptr, 16); + *number = stoi((*hexString), nullptr, 16); } @@ -276,39 +276,39 @@ bool HexToInt(std::string *HexString, int *Number){ } -bool IntToHex(int *Number, std::string *HexString, int HexFill){ +bool IntToHex(int *number, std::string *hexString, int hexFill){ - stringstream StringData; - StringData << setfill('0') << hex << setw(HexFill) << (*Number); - (*HexString) = StringData.str(); + stringstream stringData; + stringData << setfill('0') << hex << setw(hexFill) << (*number); + (*hexString) = stringData.str(); return true; } -void SplitPathFilename(string *CalendarEntryHREF, string *EntryURIPath, - string *EntryFilename){ +void SplitPathFilename(string *calendarEntryHREF, string *entryURIPath, + string *entryFilename){ // Look for the last forward slash. - int LastForwardSlash = -1; - int CharSeek = 0; - string StringIterChar = ""; + int lastForwardSlash = -1; + int charSeek = 0; + string stringIterChar = ""; - for (string::iterator StringIter = CalendarEntryHREF->begin(); - StringIter != CalendarEntryHREF->end(); StringIter++){ + for (string::iterator stringIter = calendarEntryHREF->begin(); + stringIter != calendarEntryHREF->end(); stringIter++){ - StringIterChar = *StringIter; + stringIterChar = *stringIter; - if (StringIterChar == "/"){ - LastForwardSlash = CharSeek; + if (stringIterChar == "/"){ + lastForwardSlash = charSeek; } - CharSeek++; + charSeek++; } - if (LastForwardSlash == -1){ + if (lastForwardSlash == -1){ return; @@ -316,50 +316,50 @@ void SplitPathFilename(string *CalendarEntryHREF, string *EntryURIPath, // Get the string before the last hash for the path. - (*EntryURIPath) = CalendarEntryHREF->substr(0, (LastForwardSlash + 1)); + (*entryURIPath) = calendarEntryHREF->substr(0, (LastForwardSlash + 1)); // Get the string after the last hash for the filename. - (*EntryFilename) = CalendarEntryHREF->substr((LastForwardSlash + 1)); + (*entryFilename) = calendarEntryHREF->substr((LastForwardSlash + 1)); } -string OutputText(string *TextInput){ +string OutputText(string *textInput){ - string OutputTextData; - string OutputLine; - int CharSeek = 0; - int LineSeek = 0; - int MaxLineSeek = 77; + string outputTextData; + string outputLine; + int charSeek = 0; + int lineSeek = 0; + int maxLineSeek = 77; - for (CharSeek = 0; CharSeek < TextInput->size(); CharSeek++){ + for (charSeek = 0; charSeek < TextInput->size(); charSeek++){ - LineSeek++; + lineSeek++; - if (LineSeek == MaxLineSeek){ + if (lineSeek == maxLineSeek){ - if (TextInput->substr(CharSeek, 1) != "\n"){ - OutputLine += TextInput->substr(CharSeek, 1); + if (textInput->substr(charSeek, 1) != "\n"){ + outputLine += textInput->substr(charSeek, 1); } - OutputLine += "\n"; - OutputTextData += OutputLine; - OutputLine = " "; - LineSeek = 0; - MaxLineSeek = 76; + outputLine += "\n"; + outputTextData += OutputLine; + outputLine = " "; + lineSeek = 0; + maxLineSeek = 76; continue; } - OutputLine += TextInput->substr(CharSeek, 1); + outputLine += textInput->substr(charSeek, 1); } - if (OutputLine != " "){ + if (outputLine != " "){ - OutputTextData += OutputLine; + outputTextData += outputLine; } - return OutputTextData; + return outputTextData; } \ No newline at end of file