Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added copyright and licence header to C++ files and headers for the common directory.
[xestiaab/.git] / source / common / textprocessing.cpp
1 // textprocessing.cpp - Text processing subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include <wx/wx.h>
20 #include <iostream>
21 #include <iomanip>
22 #include <string.h>
23 #include <map>
24 #include "textprocessing.h"
26 void EscapeString(wxString *ReceivedString, bool StripQuotes)
27 {
29         ReceivedString->Replace(wxT("\\"), wxT("\\\\"), TRUE);
30         ReceivedString->Replace(wxT(","), wxT("\\,"), TRUE);
31         ReceivedString->Replace(wxT(";"), wxT("\\;"), TRUE);
32         ReceivedString->Replace(wxT("\r\n"), wxT("\\n"), TRUE);
33         ReceivedString->Replace(wxT("\n"), wxT("\\n"), TRUE);
34         
35         if (StripQuotes == TRUE){
36         
37                 ReceivedString->Replace(wxT("\""), wxT(""), TRUE);
38                 
39         }
41 }
43 void GetEscapeString(wxTextCtrl *TextCtrl, wxString *ProcessString, bool StripQuotes)
44 {
46         *ProcessString = TextCtrl->GetValue();
47         EscapeString(ProcessString, StripQuotes);
49 }
51 void GetEscapeString(wxComboBox *ComboCtrl, wxString *ProcessString, bool StripQuotes)
52 {
54         *ProcessString = ComboCtrl->GetValue();
55         EscapeString(ProcessString, StripQuotes);
57 }
59 void GetEscapeString(wxChoice *ChoiceCtrl, wxString *ProcessString, bool StripQuotes)
60 {
62         *ProcessString = ChoiceCtrl->GetString(ChoiceCtrl->GetSelection());
63         EscapeString(ProcessString, StripQuotes);
65 }
67 void CaptureString(wxString *ProcessString, bool StripQuotes)
68 {
70         ProcessString->Replace(wxT("\\n"), wxT("\n"), TRUE);
71         ProcessString->Replace(wxT("\\;"), wxT(";"), TRUE);
72         ProcessString->Replace(wxT("\\,"), wxT(","), TRUE);
73         ProcessString->Replace(wxT("\\\\"), wxT("\\"), TRUE);
74         
75         if (StripQuotes == TRUE){
76         
77                 ProcessString->Replace(wxT("\""), wxT(""), TRUE);
78         
79         }
81 }
83 void ConvertToHTML(wxString *ProcessString)
84 {
86         ProcessString->Replace(wxT("&"), wxT("&amp;"), TRUE);
87         ProcessString->Replace(wxT("<"), wxT("&lt;"), TRUE);
88         ProcessString->Replace(wxT(">"), wxT("&gt;"), TRUE);
89         ProcessString->Replace(wxT("\n"), wxT("<br>"), TRUE);
91 }
93 void DeleteMapDataProcess(int IndexNum, std::map<int, std::string>* MapData){
94         MapData->erase(IndexNum);
95 }
97 void DeleteMapDataProcess(int IndexNum, std::map<int, wxString>* MapData){
98         MapData->erase(IndexNum);
99 }
101 void DeleteMapDataProcess(int IndexNum, std::map<int, int>* MapData){
102         MapData->erase(IndexNum);
105 void DeleteMapDataProcess(int IndexNum, std::map<int, bool>* MapData){
106         MapData->erase(IndexNum);
109 /*
110 template <typename ArgMap, typename... Args>
111 void DeleteMapData(ArgMap* ArgMapPtr, Args*... ArgsList){
113         //DeleteMapDataProcess(ArgMapPtr);
115         DeleteMapData(ArgsList...);
118 */
119 /*
120 void test(int* x) {
123 */
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy