5 multimap<string, string> ProcessTextVectors(vector<string> *TextProperties,
6 vector<string> *TextValues,
10 multimap<string,string> ProcessResult;
12 // Go through each of the values.
14 int TextSeekCount = 0;
15 int TextPropertySize = 0;
16 int PropertySeekCount = 0;
17 string PropertyName = "";
18 int PropertyNameSize = 0;
21 for (vector<string>::iterator iter = TextProperties->begin();
22 iter != TextProperties->end(); iter++){
24 TextPropertySize = iter->size();
26 if (TextPropertySize == 0){
28 // Text property size is 0. Go to the next
35 // Get the property data up to the first semi-colon.
37 while (TextSeekCount < TextPropertySize){
39 BufferChar = (*iter)[TextSeekCount];
41 if (BufferChar == ';'){
45 PropertyName += BufferChar;
51 if (*iter == Property || PropertyName == Property){
53 ProcessResult.insert(make_pair((*TextProperties)[PropertySeekCount],
54 (*TextValues)[PropertySeekCount]));
56 // Check to continue if one is found.
58 if (SearchMultiple == false){
60 // Found one, don't search for anymore.
79 map<string, string> SplitValues(string InputData){
81 map<string,string> FinalSplitValues;
82 map<int,int> SplitPoints;
83 map<int,int> SplitLength;
84 size_t intPropertyLen = InputData.size();
85 int intSplitsFound = 0;
88 int intPrevSplitFound = 0;
90 // Get the split points.
92 for (int i = 0; i <= intPropertyLen; i++){
96 InputData.substr(intPrevSplitFound, intSplitSize);
98 if (InputData.substr(i, 1) == ";" &&
99 InputData.substr((i - 1), 1) != "\\"){
101 if (intSplitsFound > 0){
103 // Split the value into two.
105 PropertyNameValue NVData = SplitNameValue(InputData.substr(intPrevSplitFound, (intSplitSize - 1)));
107 if (FinalSplitValues.find(NVData.Name) != FinalSplitValues.end()){
108 FinalSplitValues.insert(make_pair(NVData.Name, NVData.Value));
110 FinalSplitValues[NVData.Name] = NVData.Value;
115 intPrevSplitFound = i + 1;
123 if (intSplitsFound > 0){
125 PropertyNameValue NVData = SplitNameValue(InputData.substr(intPrevSplitFound, (intSplitSize - 1)));
127 if (FinalSplitValues.find(NVData.Name) != FinalSplitValues.end()){
128 FinalSplitValues.insert(make_pair(NVData.Name, NVData.Value));
130 FinalSplitValues[NVData.Name] = NVData.Value;
135 return FinalSplitValues;
139 PropertyNameValue SplitNameValue(string InputData){
141 PropertyNameValue FinalNameValue;
142 int InputDataLength = InputData.size();
144 bool QuoteMode = false;
145 bool DataFound = false;
147 while (SeekCount < InputDataLength){
149 if (InputData[SeekCount] == '='){
151 FinalNameValue.Name = InputData.substr(0, SeekCount);
154 FinalNameValue.Value = InputData.substr((SeekCount + 1));
157 catch (const out_of_range &oor){
158 // Do nothing. Have an empty final value.
169 if (DataFound == false){
171 FinalNameValue.Name = InputData;
175 // Check if the value has quotes at the start and end.
176 // Remove them if this is the case.
178 if (FinalNameValue.Value.front() == '\"' &&
179 FinalNameValue.Value.back() == '\"'){
181 FinalNameValue.Value.erase(0, 1);
182 FinalNameValue.Value.erase((FinalNameValue.Value.size() - 1), 1);
186 return FinalNameValue;
190 bool HexToInt(std::string *HexString, int *Number){
192 // Check that each character in the string is a number
193 // or a letter (a-f/A-F).
198 for (int CharSeek = 0;
199 CharSeek < HexString->size(); CharSeek++){
201 // Check if character is a number (0-9).
203 Char = HexString->at(CharSeek);
213 // Check if character is a letter (A-F)
222 // Check if character is a letter (a-f).
231 // Exit from subroutine as character is invalid.
237 // Convert a Hex value that is in string to integer.
241 *Number = stoi((*HexString), nullptr, 16);
245 catch (const std::invalid_argument &err){
251 catch (const std::out_of_range &err){
261 bool IntToHex(int *Number, std::string *HexString, int HexFill){
263 stringstream StringData;
264 StringData << setfill('0') << hex << setw(HexFill) << (*Number);
265 (*HexString) = StringData.str();
271 void SplitPathFilename(string *CalendarEntryHREF, string *EntryURIPath,
272 string *EntryFilename){
274 // Look for the last forward slash.
276 int LastForwardSlash = -1;
278 string StringIterChar = "";
280 for (string::iterator StringIter = CalendarEntryHREF->begin();
281 StringIter != CalendarEntryHREF->end(); StringIter++){
283 StringIterChar = *StringIter;
285 if (StringIterChar == "/"){
286 LastForwardSlash = CharSeek;
293 if (LastForwardSlash == -1){
299 // Get the string before the last hash for the path.
301 (*EntryURIPath) = CalendarEntryHREF->substr(0, (LastForwardSlash + 1));
303 // Get the string after the last hash for the filename.
305 (*EntryFilename) = CalendarEntryHREF->substr((LastForwardSlash + 1));
309 string OutputText(string *TextInput){
311 string OutputTextData;
315 int MaxLineSeek = 77;
317 for (CharSeek = 0; CharSeek < TextInput->size(); CharSeek++){
321 if (LineSeek == MaxLineSeek){
323 if (TextInput->substr(CharSeek, 1) != "\n"){
324 OutputLine += TextInput->substr(CharSeek, 1);
327 OutputTextData += OutputLine;
335 OutputLine += TextInput->substr(CharSeek, 1);
339 if (OutputLine != " "){
341 OutputTextData += OutputLine;
345 return OutputTextData;