Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Fixed potential crash with frmContactEditorKey in Edit mode.
[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 ResetUnusedString(wxString *ProcessString)
84 {
86         ProcessString->Replace(wxT("\\\\"), wxT("\\"), TRUE);
87         ProcessString->Replace(wxT("\n"), wxT(""), TRUE);
88         ProcessString->Replace(wxT("\\;"), wxT(";"), TRUE);
89         ProcessString->Replace(wxT("\\,"), wxT(","), TRUE);
91 }
93 void ConvertToHTML(wxString *ProcessString)
94 {
96         ProcessString->Replace(wxT("&"), wxT("&amp;"), TRUE);
97         ProcessString->Replace(wxT("<"), wxT("&lt;"), TRUE);
98         ProcessString->Replace(wxT(">"), wxT("&gt;"), TRUE);
99         ProcessString->Replace(wxT("\n"), wxT("<br>"), TRUE);
103 void DeleteMapDataProcess(int IndexNum, std::map<int, std::string>* MapData){
104         MapData->erase(IndexNum);
107 void DeleteMapDataProcess(int IndexNum, std::map<int, wxString>* MapData){
108         MapData->erase(IndexNum);
111 void DeleteMapDataProcess(int IndexNum, std::map<int, int>* MapData){
112         MapData->erase(IndexNum);
115 void DeleteMapDataProcess(int IndexNum, std::map<int, bool>* MapData){
116         MapData->erase(IndexNum);
119 bool MapDataExists(int *ItemIndex, std::map<int,wxString> *MapPtr){
121         if (MapPtr->find(*ItemIndex) == MapPtr->end()){
122         
123                 return FALSE;
124         
125         } else {
126         
127                 return TRUE;
128         
129         }
133 bool MapDataExists(int *ItemIndex, std::map<int,int> *MapPtr){
135         if (MapPtr->find(*ItemIndex) == MapPtr->end()){
136         
137                 return FALSE;
138         
139         } else {
140         
141                 return TRUE;
142         
143         }
147 /*
148 template <typename ArgMap, typename... Args>
149 void DeleteMapData(ArgMap* ArgMapPtr, Args*... ArgsList){
151         //DeleteMapDataProcess(ArgMapPtr);
153         DeleteMapData(ArgsList...);
156 */
157 /*
158 void test(int* x) {
161 */
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