├── Craig Chapman └── RADServerSample │ └── src │ ├── cpp │ ├── client │ │ ├── EmployeeClientC.cbproj │ │ ├── EmployeeClientC.cpp │ │ ├── EmployeeClientCPCH1.h │ │ ├── frmMain.cpp │ │ ├── frmMain.fmx │ │ └── frmMain.h │ └── server │ │ ├── RADServerC.cbproj │ │ ├── RADServerC.cpp │ │ ├── moduleMain.cpp │ │ ├── moduleMain.dfm │ │ └── moduleMain.h │ ├── delphi │ ├── client │ │ ├── EmployeesClientD.dpr │ │ ├── EmployeesClientD.dproj │ │ ├── formMain.fmx │ │ └── formMain.pas │ └── server │ │ ├── RADServerD.dpk │ │ ├── RADServerD.dproj │ │ ├── moduleMain.dfm │ │ └── moduleMain.pas │ └── grpRADServerSample.groupproj ├── David Millington ├── Learning C++ with C++Builder - Calculator │ ├── CppSuperCalculator.cbproj │ ├── CppSuperCalculator.cpp │ ├── CppSuperCalculatorPCH1.h │ ├── README.md │ ├── uCalculator.cpp │ ├── uCalculator.h │ ├── uFormCalculator.cpp │ ├── uFormCalculator.fmx │ ├── uFormCalculator.h │ ├── uInterfaces.cpp │ ├── uInterfaces.h │ ├── uOperator.cpp │ └── uOperator.h └── README.md └── README.md /Craig Chapman/RADServerSample/src/cpp/client/EmployeeClientC.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #ifdef _WIN32 5 | #include 6 | #endif 7 | #pragma hdrstop 8 | #include 9 | //--------------------------------------------------------------------------- 10 | USEFORM("frmMain.cpp", Form2); 11 | //--------------------------------------------------------------------------- 12 | extern "C" int FMXmain() 13 | { 14 | try 15 | { 16 | Application->Initialize(); 17 | Application->CreateForm(__classid(TForm2), &Form2); 18 | Application->Run(); 19 | } 20 | catch (Exception &exception) 21 | { 22 | Application->ShowException(&exception); 23 | } 24 | catch (...) 25 | { 26 | try 27 | { 28 | throw Exception(""); 29 | } 30 | catch (Exception &exception) 31 | { 32 | Application->ShowException(&exception); 33 | } 34 | } 35 | return 0; 36 | } 37 | //--------------------------------------------------------------------------- 38 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/cpp/client/EmployeeClientCPCH1.h: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef _WIN32 3 | #include 4 | #endif 5 | 6 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/cpp/client/frmMain.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | 6 | #include "frmMain.h" 7 | //--------------------------------------------------------------------------- 8 | #pragma package(smart_init) 9 | #pragma resource "*.fmx" 10 | TForm2 *Form2; 11 | //--------------------------------------------------------------------------- 12 | __fastcall TForm2::TForm2(TComponent* Owner) 13 | : TForm(Owner) 14 | { 15 | } 16 | 17 | //--------------------------------------------------------------------------- 18 | void TForm2::ClearForm() 19 | { 20 | spedEmployeeNumber->Value = 0; 21 | edFirstName->Text = ""; 22 | edLastName->Text = ""; 23 | edtPhoneExt->Text = ""; 24 | spedDepartmentNumber->Value = 0; 25 | edtJobCode->Text = ""; 26 | edtJobGrade->Text = ""; 27 | edtJobCountry->Text = ""; 28 | spedSalary->Value = 0.0; 29 | dtedHireDate->DateTime = Now(); 30 | } 31 | 32 | //--------------------------------------------------------------------------- 33 | void TForm2::JSONToForm() 34 | { 35 | TJSONObject* o; 36 | // ClearForm; 37 | if (fJSONArray->Count>0) { 38 | o = (TJSONObject*) fJSONArray->Items[fCurrentIndex]; 39 | spedEmployeeNumber->Value = StrToInt( o->GetValue("EmployeeNumber")->Value() ); 40 | edFirstName->Text = o->GetValue("FirstName")->Value(); 41 | edLastName->Text = o->GetValue("LastName")->Value(); 42 | if (!(o->GetValue("PhoneExt")==NULL)) { 43 | edtPhoneExt->Text = o->GetValue("PhoneExt")->Value(); 44 | } 45 | spedDepartmentNumber->Value = StrToFloat( o->GetValue("DepartmentNumber")->Value() ); 46 | edtJobCode->Text = o->GetValue("JobCode")->Value(); 47 | edtJobGrade->Text = o->GetValue("JobGrade")->Value(); 48 | edtJobCountry->Text = o->GetValue("JobCountry")->Value(); 49 | spedSalary->Text = o->GetValue("Salary")->Value(); 50 | dtedHireDate->DateTime = StrToDateTime( o->GetValue("HireDate")->Value() ); 51 | } 52 | } 53 | 54 | //--------------------------------------------------------------------------- 55 | void TForm2::CreateMode() 56 | { 57 | // Read Only 58 | edFirstName->ReadOnly = False; 59 | edLastName->ReadOnly = False; 60 | edtPhoneExt->ReadOnly = False; 61 | edtJobCode->ReadOnly = False; 62 | edtJobGrade->ReadOnly = False; 63 | spedSalary->ReadOnly = False; 64 | edtJobCountry->ReadOnly = False; 65 | dtedHireDate->ReadOnly = False; 66 | // Text Prompt 67 | edFirstName->TextPrompt = "First Name"; 68 | edLastName->TextPrompt = "Last Name"; 69 | edtPhoneExt->TextPrompt = "Phone Ext"; 70 | spedDepartmentNumber->TextPrompt = "Dept No"; 71 | spedDepartmentNumber->ReadOnly = False; 72 | edtJobCode->TextPrompt = "Job Code"; 73 | edtJobGrade->TextPrompt = "Job Grade"; 74 | edtJobCountry->TextPrompt = "Job Country"; 75 | spedSalary->TextPrompt = "0.0"; 76 | // Text Color 77 | edFirstName->TextSettings->FontColor = TAlphaColorRec::Red; 78 | edLastName->TextSettings->FontColor = TAlphaColorRec::Red; 79 | edtPhoneExt->TextSettings->FontColor = TAlphaColorRec::Red; 80 | spedDepartmentNumber->TextSettings->FontColor = TAlphaColorRec::Red; 81 | edtJobCode->TextSettings->FontColor = TAlphaColorRec::Red; 82 | edtJobGrade->TextSettings->FontColor = TAlphaColorRec::Red; 83 | edtJobCountry->TextSettings->FontColor = TAlphaColorRec::Red; 84 | spedSalary->TextSettings->FontColor = TAlphaColorRec::Red; 85 | dtedHireDate->TextSettings->FontColor = TAlphaColorRec::Red; 86 | // adjust buttons 87 | btnRead->Enabled = False; 88 | btnNext->Enabled = False; 89 | btnPrev->Enabled = False; 90 | btnLast->Enabled = False; 91 | btnFirst->Enabled = False; 92 | btnCreate->Enabled = False; 93 | btnCommit->Enabled = True; 94 | btnEdit->Enabled = False; 95 | btnUpdate->Enabled = False; 96 | btnDelete->Enabled = False; 97 | } 98 | 99 | //--------------------------------------------------------------------------- 100 | void TForm2::BrowseMode() 101 | { 102 | spedEmployeeNumber->Enabled = True; 103 | // Read only 104 | edFirstName->ReadOnly = True; 105 | edLastName->ReadOnly = True; 106 | edtPhoneExt->ReadOnly = True; 107 | edtJobCode->ReadOnly = True; 108 | edtJobGrade->ReadOnly = True; 109 | edtJobCountry->ReadOnly = True; 110 | spedSalary->ReadOnly = True; 111 | spedDepartmentNumber->ReadOnly = True; 112 | dtedHireDate->ReadOnly = True; 113 | // Text prompt 114 | edFirstName->TextPrompt = ""; 115 | edLastName->TextPrompt = ""; 116 | edtPhoneExt->TextPrompt = ""; 117 | spedDepartmentNumber->TextPrompt = ""; 118 | edtJobCode->TextPrompt = ""; 119 | edtJobGrade->TextPrompt = ""; 120 | edtJobCountry->TextPrompt = ""; 121 | spedSalary->TextPrompt = ""; 122 | // Text Color 123 | edFirstName->TextSettings->FontColor = TAlphaColorRec::Black; 124 | edLastName->TextSettings->FontColor = TAlphaColorRec::Black; 125 | edtPhoneExt->TextSettings->FontColor = TAlphaColorRec::Black; 126 | spedDepartmentNumber->TextSettings->FontColor = TAlphaColorRec::Black; 127 | edtJobCode->TextSettings->FontColor = TAlphaColorRec::Black; 128 | edtJobGrade->TextSettings->FontColor = TAlphaColorRec::Black; 129 | edtJobCountry->TextSettings->FontColor = TAlphaColorRec::Black; 130 | spedSalary->TextSettings->FontColor = TAlphaColorRec::Black; 131 | dtedHireDate->TextSettings->FontColor = TAlphaColorRec::Black; 132 | // adjust buttons 133 | btnRead->Enabled = True; 134 | btnNext->Enabled = True; 135 | btnPrev->Enabled = True; 136 | btnLast->Enabled = True; 137 | btnFirst->Enabled = True; 138 | btnCreate->Enabled = True; 139 | btnCommit->Enabled = False; 140 | btnEdit->Enabled = True; 141 | btnUpdate->Enabled = False; 142 | btnDelete->Enabled = True; 143 | } 144 | 145 | //--------------------------------------------------------------------------- 146 | void TForm2::EditMode() 147 | { 148 | // Read Only 149 | edFirstName->ReadOnly = False; 150 | edLastName->ReadOnly = False; 151 | edtPhoneExt->ReadOnly = False; 152 | edtJobCode->ReadOnly = False; 153 | edtJobGrade->ReadOnly = False; 154 | edtJobCountry->ReadOnly = False; 155 | spedDepartmentNumber->ReadOnly = False; 156 | spedSalary->ReadOnly = False; 157 | dtedHireDate->ReadOnly = False; 158 | // Text Prompt 159 | edFirstName->TextPrompt = "First Name"; 160 | edLastName->TextPrompt = "Last Name"; 161 | edtPhoneExt->TextPrompt = "Phone Ext"; 162 | spedDepartmentNumber->TextPrompt = "Dept No"; 163 | edtJobCode->TextPrompt = "Job Code"; 164 | edtJobGrade->TextPrompt = "Job Grade"; 165 | edtJobCountry->TextPrompt = "Job Country"; 166 | spedSalary->TextPrompt = "Salary"; 167 | // Text Color 168 | edFirstName->TextSettings->FontColor = TAlphaColorRec::Blue; 169 | edLastName->TextSettings->FontColor = TAlphaColorRec::Blue; 170 | edtPhoneExt->TextSettings->FontColor = TAlphaColorRec::Blue; 171 | spedDepartmentNumber->TextSettings->FontColor = TAlphaColorRec::Blue; 172 | edtJobCode->TextSettings->FontColor = TAlphaColorRec::Blue; 173 | edtJobGrade->TextSettings->FontColor = TAlphaColorRec::Blue; 174 | edtJobCountry->TextSettings->FontColor = TAlphaColorRec::Blue; 175 | spedSalary->TextSettings->FontColor = TAlphaColorRec::Blue; 176 | dtedHireDate->TextSettings->FontColor = TAlphaColorRec::Blue; 177 | // adjust buttons 178 | btnRead->Enabled = False; 179 | btnNext->Enabled = False; 180 | btnPrev->Enabled = False; 181 | btnLast->Enabled = False; 182 | btnFirst->Enabled = False; 183 | btnCreate->Enabled = False; 184 | btnCommit->Enabled = False; 185 | btnEdit->Enabled = False; 186 | btnUpdate->Enabled = True; 187 | btnDelete->Enabled = False; 188 | } 189 | 190 | //--------------------------------------------------------------------------- 191 | void __fastcall TForm2::btnReadClick(TObject *Sender) 192 | { 193 | //- Request data from 'employees' end-point. 194 | RESTRequest->Resource = "employees"; 195 | RESTRequest->Method = TRESTRequestMethod::rmGET; 196 | RESTRequest->Response = RESTResponse; 197 | 198 | // Make request. 199 | RESTRequest->Execute(); 200 | 201 | //- Decode the data into a class global 202 | if (fJSONArray) { 203 | fJSONArray->DisposeOf(); 204 | } 205 | fJSONArray = (TJSONArray*) TJSONObject::ParseJSONValue(RESTResponse->Content); 206 | 207 | //- set index. 208 | fCurrentIndex = 0; 209 | 210 | //- Load current resource to form. 211 | JSONToForm(); 212 | } 213 | //--------------------------------------------------------------------------- 214 | void __fastcall TForm2::btnPrevClick(TObject *Sender) 215 | { 216 | if (fCurrentIndex>0) { 217 | fCurrentIndex--; 218 | } 219 | JSONToForm(); 220 | } 221 | //--------------------------------------------------------------------------- 222 | void __fastcall TForm2::btnNextClick(TObject *Sender) 223 | { 224 | if (fCurrentIndex<(fJSONArray->Count-1)) { 225 | fCurrentIndex++; 226 | } 227 | JSONToForm(); 228 | } 229 | //--------------------------------------------------------------------------- 230 | void __fastcall TForm2::btnFirstClick(TObject *Sender) 231 | { 232 | fCurrentIndex = 0; 233 | JSONToForm(); 234 | } 235 | //--------------------------------------------------------------------------- 236 | void __fastcall TForm2::btnLastClick(TObject *Sender) 237 | { 238 | if (fJSONArray->Count>0) { 239 | fCurrentIndex = (fJSONArray->Count-1); 240 | } else { 241 | fCurrentIndex = 0; 242 | } 243 | JSONToForm(); 244 | } 245 | //--------------------------------------------------------------------------- 246 | void __fastcall TForm2::btnCreateClick(TObject *Sender) 247 | { 248 | //- Clear the form and adjust text read-only and prompts. 249 | ClearForm(); 250 | CreateMode(); 251 | } 252 | //--------------------------------------------------------------------------- 253 | void __fastcall TForm2::btnCommitClick(TObject *Sender) 254 | { 255 | //- Prepare to POST data to 'employees' end-point. 256 | RESTRequest->Resource = "employees"; 257 | RESTRequest->Method = TRESTRequestMethod::rmPOST; 258 | RESTRequest->Response = RESTResponse; 259 | 260 | //- Populate the JSON resource to post. 261 | RESTRequest->Body->ClearBody(); 262 | RESTRequest->Body->JSONWriter->WriteStartObject(); 263 | RESTRequest->Body->JSONWriter->WritePropertyName("FirstName"); 264 | RESTRequest->Body->JSONWriter->WriteValue(edFirstName->Text); 265 | RESTRequest->Body->JSONWriter->WritePropertyName("LastName"); 266 | RESTRequest->Body->JSONWriter->WriteValue(edLastName->Text); 267 | RESTRequest->Body->JSONWriter->WritePropertyName("PhoneExt"); 268 | RESTRequest->Body->JSONWriter->WriteValue(edtPhoneExt->Text); 269 | RESTRequest->Body->JSONWriter->WritePropertyName("DepartmentNumber"); 270 | RESTRequest->Body->JSONWriter->WriteValue(spedDepartmentNumber->Value); 271 | RESTRequest->Body->JSONWriter->WritePropertyName("JobCode"); 272 | RESTRequest->Body->JSONWriter->WriteValue(edtJobCode->Text); 273 | RESTRequest->Body->JSONWriter->WritePropertyName("JobGrade"); 274 | RESTRequest->Body->JSONWriter->WriteValue(edtJobGrade->Text); 275 | RESTRequest->Body->JSONWriter->WritePropertyName("JobCountry"); 276 | RESTRequest->Body->JSONWriter->WriteValue(edtJobCountry->Text); 277 | RESTRequest->Body->JSONWriter->WritePropertyName("Salary"); 278 | RESTRequest->Body->JSONWriter->WriteValue(spedSalary->Value); 279 | RESTRequest->Body->JSONWriter->WritePropertyName("HireDate"); 280 | RESTRequest->Body->JSONWriter->WriteValue(FormatDateTime("MM/DD/YYYY 00:00:00",dtedHireDate->DateTime)); 281 | RESTRequest->Body->JSONWriter->WriteEnd(); 282 | 283 | // Adjust the form to recieve the result. 284 | BrowseMode(); 285 | 286 | // Execute the request 287 | RESTRequest->Execute(); 288 | 289 | // Refresh form 290 | this->btnReadClick(Sender); 291 | } 292 | //--------------------------------------------------------------------------- 293 | void __fastcall TForm2::btnEditClick(TObject *Sender) 294 | { 295 | EditMode(); 296 | } 297 | //--------------------------------------------------------------------------- 298 | void __fastcall TForm2::btnUpdateClick(TObject *Sender) 299 | { 300 | //- Prepare to PUT data to 'employees' end-point. 301 | RESTRequest->Resource = "employees/"+spedEmployeeNumber->Text; 302 | RESTRequest->Method = TRESTRequestMethod::rmPUT; 303 | RESTRequest->Response = RESTResponse; 304 | 305 | //- Populate the JSON resource to post. 306 | RESTRequest->Body->ClearBody(); 307 | RESTRequest->Body->JSONWriter->WriteStartObject(); 308 | RESTRequest->Body->JSONWriter->WritePropertyName("FirstName"); 309 | RESTRequest->Body->JSONWriter->WriteValue(edFirstName->Text); 310 | RESTRequest->Body->JSONWriter->WritePropertyName("LastName"); 311 | RESTRequest->Body->JSONWriter->WriteValue(edLastName->Text); 312 | RESTRequest->Body->JSONWriter->WritePropertyName("PhoneExt"); 313 | RESTRequest->Body->JSONWriter->WriteValue(edtPhoneExt->Text); 314 | RESTRequest->Body->JSONWriter->WritePropertyName("DepartmentNumber"); 315 | RESTRequest->Body->JSONWriter->WriteValue(spedDepartmentNumber->Value); 316 | RESTRequest->Body->JSONWriter->WritePropertyName("JobCode"); 317 | RESTRequest->Body->JSONWriter->WriteValue(edtJobCode->Text); 318 | RESTRequest->Body->JSONWriter->WritePropertyName("JobGrade"); 319 | RESTRequest->Body->JSONWriter->WriteValue(edtJobGrade->Text); 320 | RESTRequest->Body->JSONWriter->WritePropertyName("JobCountry"); 321 | RESTRequest->Body->JSONWriter->WriteValue(edtJobCountry->Text); 322 | RESTRequest->Body->JSONWriter->WritePropertyName("Salary"); 323 | RESTRequest->Body->JSONWriter->WriteValue(spedSalary->Value); 324 | RESTRequest->Body->JSONWriter->WritePropertyName("HireDate"); 325 | RESTRequest->Body->JSONWriter->WriteValue(FormatDateTime("MM/DD/YYYY 00:00:00",dtedHireDate->DateTime)); 326 | RESTRequest->Body->JSONWriter->WriteEnd(); 327 | 328 | // Adjust the form to recieve the result. 329 | BrowseMode(); 330 | 331 | // Execute the request 332 | RESTRequest->Execute(); 333 | 334 | // Refresh form 335 | this->btnReadClick(Sender); 336 | } 337 | 338 | //--------------------------------------------------------------------------- 339 | void __fastcall TForm2::btnDeleteClick(TObject *Sender) 340 | { 341 | //- Prepare to DELETE data from 'employees' end-point. 342 | RESTRequest->Resource = "employees/"+spedEmployeeNumber->Text; 343 | RESTRequest->Method = TRESTRequestMethod::rmDELETE; 344 | RESTRequest->Response = RESTResponse; 345 | 346 | // Execute the request 347 | RESTRequest->Execute(); 348 | 349 | // Refresh form 350 | this->btnReadClick(Sender); 351 | } 352 | //--------------------------------------------------------------------------- 353 | 354 | 355 | 356 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/cpp/client/frmMain.fmx: -------------------------------------------------------------------------------- 1 | object Form2: TForm2 2 | Left = 0 3 | Top = 0 4 | Caption = 'Form2' 5 | ClientHeight = 369 6 | ClientWidth = 640 7 | FormFactor.Width = 320 8 | FormFactor.Height = 480 9 | FormFactor.Devices = [Desktop] 10 | DesignerMasterStyle = 0 11 | object Panel3: TPanel 12 | Align = Client 13 | Size.Width = 640.000000000000000000 14 | Size.Height = 297.000000000000000000 15 | Size.PlatformDefault = False 16 | TabOrder = 0 17 | object lblFirstName: TLabel 18 | Position.X = 160.000000000000000000 19 | Position.Y = 16.000000000000000000 20 | Text = 'First Name' 21 | end 22 | object lblLastName: TLabel 23 | Position.X = 296.000000000000000000 24 | Position.Y = 16.000000000000000000 25 | Text = 'Last Name' 26 | end 27 | object lblEmployeeNumber: TLabel 28 | Position.X = 16.000000000000000000 29 | Position.Y = 16.000000000000000000 30 | Text = 'Employee Number' 31 | end 32 | object lblPhoneExt: TLabel 33 | Position.X = 424.000000000000000000 34 | Position.Y = 16.000000000000000000 35 | Text = 'Phone Extension' 36 | end 37 | object lblHireDate: TLabel 38 | Position.X = 16.000000000000000000 39 | Position.Y = 64.000000000000000000 40 | Size.Width = 81.000000000000000000 41 | Size.Height = 17.000000000000000000 42 | Size.PlatformDefault = False 43 | Text = 'Hire Date' 44 | end 45 | object lblDepartmentNumber: TLabel 46 | Position.X = 160.000000000000000000 47 | Position.Y = 64.000000000000000000 48 | Size.Width = 145.000000000000000000 49 | Size.Height = 17.000000000000000000 50 | Size.PlatformDefault = False 51 | Text = 'Department Number' 52 | end 53 | object lblJobCode: TLabel 54 | Position.X = 16.000000000000000000 55 | Position.Y = 112.000000000000000000 56 | Size.Width = 81.000000000000000000 57 | Size.Height = 17.000000000000000000 58 | Size.PlatformDefault = False 59 | Text = 'Job Code' 60 | end 61 | object lblJobGrade: TLabel 62 | Position.X = 160.000000000000000000 63 | Position.Y = 112.000000000000000000 64 | Size.Width = 81.000000000000000000 65 | Size.Height = 17.000000000000000000 66 | Size.PlatformDefault = False 67 | Text = 'Job Grade' 68 | end 69 | object lblJobCountry: TLabel 70 | Position.X = 304.000000000000000000 71 | Position.Y = 112.000000000000000000 72 | Size.Width = 81.000000000000000000 73 | Size.Height = 17.000000000000000000 74 | Size.PlatformDefault = False 75 | Text = 'Job Country' 76 | end 77 | object lblSalary: TLabel 78 | Position.X = 16.000000000000000000 79 | Position.Y = 160.000000000000000000 80 | Size.Width = 81.000000000000000000 81 | Size.Height = 17.000000000000000000 82 | Size.PlatformDefault = False 83 | Text = 'Salary' 84 | end 85 | object edFirstName: TEdit 86 | Touch.InteractiveGestures = [LongTap, DoubleTap] 87 | TabOrder = 3 88 | ReadOnly = True 89 | Position.X = 160.000000000000000000 90 | Position.Y = 32.000000000000000000 91 | Size.Width = 121.000000000000000000 92 | Size.Height = 22.000000000000000000 93 | Size.PlatformDefault = False 94 | StyledSettings = [Family, Size, Style] 95 | end 96 | object edLastName: TEdit 97 | Touch.InteractiveGestures = [LongTap, DoubleTap] 98 | TabOrder = 4 99 | ReadOnly = True 100 | Position.X = 296.000000000000000000 101 | Position.Y = 32.000000000000000000 102 | Size.Width = 113.000000000000000000 103 | Size.Height = 22.000000000000000000 104 | Size.PlatformDefault = False 105 | StyledSettings = [Family, Size, Style] 106 | end 107 | object edtPhoneExt: TEdit 108 | Touch.InteractiveGestures = [LongTap, DoubleTap] 109 | TabOrder = 5 110 | ReadOnly = True 111 | Position.X = 424.000000000000000000 112 | Position.Y = 32.000000000000000000 113 | StyledSettings = [Family, Size, Style] 114 | end 115 | object edtJobCode: TEdit 116 | Touch.InteractiveGestures = [LongTap, DoubleTap] 117 | TabOrder = 8 118 | ReadOnly = True 119 | Position.X = 16.000000000000000000 120 | Position.Y = 128.000000000000000000 121 | Size.Width = 121.000000000000000000 122 | Size.Height = 22.000000000000000000 123 | Size.PlatformDefault = False 124 | StyledSettings = [Family, Size, Style] 125 | end 126 | object edtJobGrade: TEdit 127 | Touch.InteractiveGestures = [LongTap, DoubleTap] 128 | TabOrder = 9 129 | ReadOnly = True 130 | Position.X = 160.000000000000000000 131 | Position.Y = 128.000000000000000000 132 | Size.Width = 121.000000000000000000 133 | Size.Height = 22.000000000000000000 134 | Size.PlatformDefault = False 135 | StyledSettings = [Family, Size, Style] 136 | end 137 | object edtJobCountry: TEdit 138 | Touch.InteractiveGestures = [LongTap, DoubleTap] 139 | TabOrder = 10 140 | ReadOnly = True 141 | Position.X = 304.000000000000000000 142 | Position.Y = 128.000000000000000000 143 | Size.Width = 113.000000000000000000 144 | Size.Height = 22.000000000000000000 145 | Size.PlatformDefault = False 146 | StyledSettings = [Family, Size, Style] 147 | end 148 | object spedEmployeeNumber: TSpinBox 149 | Touch.InteractiveGestures = [LongTap, DoubleTap] 150 | TabOrder = 2 151 | Cursor = crIBeam 152 | Max = 10000.000000000000000000 153 | ReadOnly = True 154 | Position.X = 16.000000000000000000 155 | Position.Y = 32.000000000000000000 156 | Enabled = False 157 | Size.Width = 121.000000000000000000 158 | Size.Height = 22.000000000000000000 159 | Size.PlatformDefault = False 160 | end 161 | object spedDepartmentNumber: TSpinBox 162 | Touch.InteractiveGestures = [LongTap, DoubleTap] 163 | TabOrder = 7 164 | Cursor = crIBeam 165 | Max = 10000.000000000000000000 166 | ReadOnly = True 167 | Position.X = 160.000000000000000000 168 | Position.Y = 80.000000000000000000 169 | Size.Width = 121.000000000000000000 170 | Size.Height = 22.000000000000000000 171 | Size.PlatformDefault = False 172 | StyledSettings = [Family, Size, Style] 173 | end 174 | object dtedHireDate: TDateEdit 175 | Date = 39445.000000000000000000 176 | Position.X = 16.000000000000000000 177 | Position.Y = 80.000000000000000000 178 | ReadOnly = True 179 | Size.Width = 121.000000000000000000 180 | Size.Height = 22.000000000000000000 181 | Size.PlatformDefault = False 182 | StyledSettings = [Family, Size, Style] 183 | TabOrder = 6 184 | end 185 | object Panel1: TPanel 186 | Align = Bottom 187 | Position.Y = 230.000000000000000000 188 | Size.Width = 640.000000000000000000 189 | Size.Height = 67.000000000000000000 190 | Size.PlatformDefault = False 191 | TabOrder = 12 192 | object btnPrev: TButton 193 | Position.X = 96.000000000000000000 194 | Position.Y = 8.000000000000000000 195 | TabOrder = 1 196 | Text = 'Prev' 197 | OnClick = btnPrevClick 198 | end 199 | object btnNext: TButton 200 | Position.X = 184.000000000000000000 201 | Position.Y = 8.000000000000000000 202 | TabOrder = 0 203 | Text = 'Next' 204 | OnClick = btnNextClick 205 | end 206 | object btnRead: TButton 207 | Position.X = 8.000000000000000000 208 | Position.Y = 8.000000000000000000 209 | TabOrder = 2 210 | Text = 'Read' 211 | OnClick = btnReadClick 212 | end 213 | object btnCreate: TButton 214 | Position.X = 8.000000000000000000 215 | Position.Y = 40.000000000000000000 216 | TabOrder = 3 217 | Text = 'Create' 218 | OnClick = btnCreateClick 219 | end 220 | object btnCommit: TButton 221 | Enabled = False 222 | Position.X = 96.000000000000000000 223 | Position.Y = 40.000000000000000000 224 | TabOrder = 4 225 | Text = 'Commit' 226 | OnClick = btnCommitClick 227 | end 228 | object btnEdit: TButton 229 | Position.X = 184.000000000000000000 230 | Position.Y = 40.000000000000000000 231 | TabOrder = 5 232 | Text = 'Edit' 233 | OnClick = btnEditClick 234 | end 235 | object btnUpdate: TButton 236 | Enabled = False 237 | Position.X = 272.000000000000000000 238 | Position.Y = 40.000000000000000000 239 | TabOrder = 6 240 | Text = 'Update' 241 | OnClick = btnUpdateClick 242 | end 243 | object btnDelete: TButton 244 | Position.X = 360.000000000000000000 245 | Position.Y = 40.000000000000000000 246 | TabOrder = 7 247 | Text = 'Delete' 248 | OnClick = btnDeleteClick 249 | end 250 | object btnFirst: TButton 251 | Position.X = 272.000000000000000000 252 | Position.Y = 8.000000000000000000 253 | TabOrder = 8 254 | Text = 'First' 255 | OnClick = btnFirstClick 256 | end 257 | object btnLast: TButton 258 | Position.X = 360.000000000000000000 259 | Position.Y = 9.000000000000000000 260 | TabOrder = 25 261 | Text = 'Last' 262 | OnClick = btnLastClick 263 | end 264 | end 265 | object spedSalary: TSpinBox 266 | Touch.InteractiveGestures = [LongTap, DoubleTap] 267 | TabOrder = 11 268 | Cursor = crIBeam 269 | Max = 1000000.000000000000000000 270 | ValueType = Float 271 | Increment = 1000.000000000000000000 272 | ReadOnly = True 273 | Position.X = 16.000000000000000000 274 | Position.Y = 176.000000000000000000 275 | Size.Width = 169.000000000000000000 276 | Size.Height = 22.000000000000000000 277 | Size.PlatformDefault = False 278 | StyledSettings = [Family, Size, Style] 279 | end 280 | end 281 | object Panel2: TPanel 282 | Align = Bottom 283 | Position.Y = 297.000000000000000000 284 | Size.Width = 640.000000000000000000 285 | Size.Height = 72.000000000000000000 286 | Size.PlatformDefault = False 287 | TabOrder = 19 288 | end 289 | object RESTClient: TRESTClient 290 | Accept = 'application/json, text/plain; q=0.9, text/html;q=0.8,' 291 | AcceptCharset = 'UTF-8, *;q=0.8' 292 | BaseURL = 'http://127.0.0.1:8080/' 293 | Params = <> 294 | HandleRedirects = True 295 | Left = 40 296 | Top = 312 297 | end 298 | object RESTRequest: TRESTRequest 299 | Client = RESTClient 300 | Params = <> 301 | Resource = 'employees' 302 | Response = RESTResponse 303 | SynchronizedEvents = False 304 | Left = 120 305 | Top = 312 306 | end 307 | object RESTResponse: TRESTResponse 308 | ContentType = 'application/json' 309 | Left = 208 310 | Top = 312 311 | end 312 | end 313 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/cpp/client/frmMain.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef frmMainH 4 | #define frmMainH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | //--------------------------------------------------------------------------- 21 | class TForm2 : public TForm 22 | { 23 | __published: // IDE-managed Components 24 | TPanel *Panel3; 25 | TLabel *lblFirstName; 26 | TLabel *lblLastName; 27 | TLabel *lblEmployeeNumber; 28 | TLabel *lblPhoneExt; 29 | TLabel *lblHireDate; 30 | TLabel *lblDepartmentNumber; 31 | TLabel *lblJobCode; 32 | TLabel *lblJobGrade; 33 | TLabel *lblJobCountry; 34 | TLabel *lblSalary; 35 | TEdit *edFirstName; 36 | TEdit *edLastName; 37 | TEdit *edtPhoneExt; 38 | TEdit *edtJobCode; 39 | TEdit *edtJobGrade; 40 | TEdit *edtJobCountry; 41 | TSpinBox *spedEmployeeNumber; 42 | TSpinBox *spedDepartmentNumber; 43 | TDateEdit *dtedHireDate; 44 | TPanel *Panel1; 45 | TButton *btnPrev; 46 | TButton *btnNext; 47 | TButton *btnRead; 48 | TButton *btnCreate; 49 | TButton *btnCommit; 50 | TButton *btnEdit; 51 | TButton *btnUpdate; 52 | TButton *btnDelete; 53 | TButton *btnFirst; 54 | TButton *btnLast; 55 | TSpinBox *spedSalary; 56 | TPanel *Panel2; 57 | TRESTClient *RESTClient; 58 | TRESTRequest *RESTRequest; 59 | TRESTResponse *RESTResponse; 60 | void __fastcall btnReadClick(TObject *Sender); 61 | void __fastcall btnPrevClick(TObject *Sender); 62 | void __fastcall btnNextClick(TObject *Sender); 63 | void __fastcall btnFirstClick(TObject *Sender); 64 | void __fastcall btnLastClick(TObject *Sender); 65 | void __fastcall btnCreateClick(TObject *Sender); 66 | void __fastcall btnCommitClick(TObject *Sender); 67 | void __fastcall btnEditClick(TObject *Sender); 68 | void __fastcall btnUpdateClick(TObject *Sender); 69 | void __fastcall btnDeleteClick(TObject *Sender); 70 | private: // User declarations 71 | TJSONArray* fJSONArray; 72 | int fCurrentIndex; 73 | private: 74 | void JSONToForm(); 75 | void ClearForm(); 76 | void CreateMode(); 77 | void BrowseMode(); 78 | void EditMode(); 79 | public: // User declarations 80 | __fastcall TForm2(TComponent* Owner); 81 | }; 82 | //--------------------------------------------------------------------------- 83 | extern PACKAGE TForm2 *Form2; 84 | //--------------------------------------------------------------------------- 85 | #endif 86 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/cpp/server/RADServerC.cbproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {A6B901E2-1D98-4334-A40D-9A00F6513687} 4 | 18.4 5 | None 6 | RADServerC.cpp 7 | True 8 | Debug 9 | Win32 10 | 3 11 | Package 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Cfg_1 34 | true 35 | true 36 | 37 | 38 | true 39 | Base 40 | true 41 | 42 | 43 | true 44 | Cfg_2 45 | true 46 | true 47 | 48 | 49 | JPHNE 50 | true 51 | true 52 | ..\..\..\out\lib\$(Platform)\$(Config) 53 | ..\..\..\out\bin\$(Platform)\$(Config) 54 | false 55 | true 56 | true 57 | $(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath) 58 | CppPackage 59 | CloudService;DataSnapFireDAC;emsclient;emsclientfiredac;FireDAC;FireDACCommon;FireDACCommonDriver;FireDACIBDriver;FireDACSqliteDriver;inet;RESTBackendComponents;RESTComponents;soapmidas;soaprtl;soapserver;$(PackageImports) 60 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 61 | true 62 | -l"$(TargetName)" 63 | $(BDS)\bin\cbuilder_PROJECTICON.ico 64 | $(BDS)\bin\cbuilder_PROJECTICNS.icns 65 | rtl.lib;emsserverapi.lib;FireDAC.lib;FireDACCommonDriver.lib;FireDACCommon.lib; 66 | RADServerSample\src\cpp\server\;$(IncludePath) 67 | RADServerSample\src\cpp\server\;$(ILINK_LibraryPath) 68 | RADServerC 69 | 1033 70 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 71 | 72 | 73 | adortl;appanalytics;bcbie;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindengine;CustomIPTransport;DataSnapClient;DataSnapCommon;DataSnapConnectors;DatasnapConnectorsFreePascal;DataSnapIndy10ServerTransport;DataSnapNativeClient;DataSnapProviderClient;DataSnapServer;DataSnapServerMidas;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXDb2Driver;DBXFirebirdDriver;DBXInformixDriver;DBXInterBaseDriver;DBXMSSQLDriver;DBXMySQLDriver;DBXOdbcDriver;DBXOracleDriver;DBXSqliteDriver;DBXSybaseASADriver;DBXSybaseASEDriver;dsnap;dsnapcon;dsnapxml;emsedge;emshosting;FireDACADSDriver;FireDACASADriver;FireDACCommonODBC;FireDACDb2Driver;FireDACDBXDriver;FireDACDSDriver;FireDACInfxDriver;FireDACMongoDBDriver;FireDACMSAccDriver;FireDACMSSQLDriver;FireDACMySQLDriver;FireDACODBCDriver;FireDACOracleDriver;FireDACPgDriver;FireDACTDataDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;FMXTee;FmxTeeUI;ibmonitor;ibxbindings;ibxpress;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inetdb;inetdbxpress;Intraweb;jsonadapt;pkg_deREST;rtl;svn;SynEditDR;Tee;TeeDB;TeeUI;tethering;vcl;vclactnband;vcldb;vcldsnap;vclFireDAC;vclib;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports) 74 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 75 | Debug 76 | true 77 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 78 | 1033 79 | $(BDS)\bin\EMSDevServer.exe 80 | 81 | 82 | adortl;appanalytics;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindengine;CustomIPTransport;DataSnapClient;DataSnapCommon;DataSnapConnectors;DatasnapConnectorsFreePascal;DataSnapIndy10ServerTransport;DataSnapNativeClient;DataSnapProviderClient;DataSnapServer;DataSnapServerMidas;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXDb2Driver;DBXFirebirdDriver;DBXInformixDriver;DBXInterBaseDriver;DBXMSSQLDriver;DBXMySQLDriver;DBXOdbcDriver;DBXOracleDriver;DBXSqliteDriver;DBXSybaseASADriver;DBXSybaseASEDriver;dsnap;dsnapcon;dsnapxml;emsedge;emshosting;FireDACADSDriver;FireDACASADriver;FireDACCommonODBC;FireDACDb2Driver;FireDACDBXDriver;FireDACDSDriver;FireDACInfxDriver;FireDACMongoDBDriver;FireDACMSAccDriver;FireDACMSSQLDriver;FireDACMySQLDriver;FireDACODBCDriver;FireDACOracleDriver;FireDACPgDriver;FireDACTDataDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;FMXTee;FmxTeeUI;ibmonitor;ibxbindings;ibxpress;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inetdb;inetdbxpress;Intraweb;pkg_deREST;rtl;SynEditDR;Tee;TeeDB;TeeUI;tethering;vcl;vclactnband;vcldb;vcldsnap;vclFireDAC;vclib;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports) 83 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) 84 | Debug 85 | true 86 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 87 | 1033 88 | $(BDS)\bin64\EMSDevServer.exe 89 | 90 | 91 | false 92 | true 93 | false 94 | true 95 | _DEBUG;$(Defines) 96 | false 97 | None 98 | DEBUG 99 | true 100 | true 101 | true 102 | true 103 | Full 104 | true 105 | true 106 | true 107 | true 108 | true 109 | $(BDSLIB)\$(PLATFORM)\debug;$(ILINK_LibraryPath) 110 | $(BDSLIB)\$(PLATFORM)\debug\$(LANGDIR);$(ILINK_TranslatedLibraryPath) 111 | 112 | 113 | rtl.bpi;FireDAC.bpi;FireDACCommonDriver.bpi;FireDACCommon.bpi 114 | emsserverapi.lib 115 | true 116 | 1033 117 | 118 | 119 | NDEBUG;$(Defines) 120 | None 121 | 122 | 123 | rtl.bpi;FireDAC.bpi;FireDACCommonDriver.bpi;FireDACCommon.bpi 124 | emsserverapi.lib 125 | 126 | 127 | 128 | 5 129 | 130 | 131 | 6 132 | 133 | 134 | 7 135 | 136 | 137 | 4 138 | 139 | 140 | 1 141 | 142 | 143 |
EmployeesResource1
144 | dfm 145 | TDataModule 146 | moduleMain.h 147 | 3 148 |
149 | 150 | 0 151 | 152 | 153 | 2 154 | 155 | 156 | 157 | Cfg_2 158 | Base 159 | 160 | 161 | Base 162 | 163 | 164 | Cfg_1 165 | Base 166 | 167 |
168 | 169 | CPlusPlusBuilder.Personality.12 170 | CppPackage 171 | 172 | 173 | 174 | RADServerC.cpp 175 | 176 | 177 | False 178 | True 179 | True 180 | False 181 | 182 | 183 | Microsoft Office 2000 Sample Automation Server Wrapper Components 184 | Microsoft Office XP Sample Automation Server Wrapper Components 185 | Embarcadero C++Builder Office 2000 Servers Package 186 | Embarcadero C++Builder Office XP Servers Package 187 | 188 | 189 | 190 | 191 | 192 | RADServerC.bpl 193 | true 194 | 195 | 196 | 197 | 198 | true 199 | 200 | 201 | 202 | 203 | true 204 | 205 | 206 | 207 | 208 | true 209 | 210 | 211 | 212 | 213 | true 214 | 215 | 216 | 217 | 218 | true 219 | 220 | 221 | 222 | 223 | true 224 | 225 | 226 | 227 | 228 | true 229 | 230 | 231 | 232 | 233 | true 234 | 235 | 236 | 237 | 238 | true 239 | 240 | 241 | 242 | 243 | true 244 | 245 | 246 | 247 | 248 | true 249 | 250 | 251 | 252 | 253 | true 254 | 255 | 256 | 257 | 258 | true 259 | 260 | 261 | 262 | 263 | RADServerC.bpl 264 | true 265 | 266 | 267 | 268 | 269 | true 270 | 271 | 272 | 273 | 274 | 1 275 | 276 | 277 | Contents\MacOS 278 | 0 279 | 280 | 281 | 282 | 283 | classes 284 | 1 285 | 286 | 287 | 288 | 289 | library\lib\armeabi-v7a 290 | 1 291 | 292 | 293 | 294 | 295 | library\lib\armeabi 296 | 1 297 | 298 | 299 | 300 | 301 | library\lib\mips 302 | 1 303 | 304 | 305 | 306 | 307 | library\lib\armeabi-v7a 308 | 1 309 | 310 | 311 | 312 | 313 | res\drawable 314 | 1 315 | 316 | 317 | 318 | 319 | res\values 320 | 1 321 | 322 | 323 | 324 | 325 | res\drawable 326 | 1 327 | 328 | 329 | 330 | 331 | res\drawable-xxhdpi 332 | 1 333 | 334 | 335 | 336 | 337 | res\drawable-ldpi 338 | 1 339 | 340 | 341 | 342 | 343 | res\drawable-mdpi 344 | 1 345 | 346 | 347 | 348 | 349 | res\drawable-hdpi 350 | 1 351 | 352 | 353 | 354 | 355 | res\drawable-xhdpi 356 | 1 357 | 358 | 359 | 360 | 361 | res\drawable-small 362 | 1 363 | 364 | 365 | 366 | 367 | res\drawable-normal 368 | 1 369 | 370 | 371 | 372 | 373 | res\drawable-large 374 | 1 375 | 376 | 377 | 378 | 379 | res\drawable-xlarge 380 | 1 381 | 382 | 383 | 384 | 385 | 1 386 | 387 | 388 | 1 389 | 390 | 391 | 0 392 | 393 | 394 | 395 | 396 | 1 397 | .framework 398 | 399 | 400 | 0 401 | 402 | 403 | 404 | 405 | 1 406 | .dylib 407 | 408 | 409 | 0 410 | .dll;.bpl 411 | 412 | 413 | 414 | 415 | 1 416 | .dylib 417 | 418 | 419 | 1 420 | .dylib 421 | 422 | 423 | 1 424 | .dylib 425 | 426 | 427 | 1 428 | .dylib 429 | 430 | 431 | 0 432 | .bpl 433 | 434 | 435 | 436 | 437 | 0 438 | 439 | 440 | 0 441 | 442 | 443 | 0 444 | 445 | 446 | 0 447 | 448 | 449 | 0 450 | 451 | 452 | 0 453 | 454 | 455 | 456 | 457 | 1 458 | 459 | 460 | 1 461 | 462 | 463 | 1 464 | 465 | 466 | 467 | 468 | 1 469 | 470 | 471 | 1 472 | 473 | 474 | 1 475 | 476 | 477 | 478 | 479 | 1 480 | 481 | 482 | 1 483 | 484 | 485 | 1 486 | 487 | 488 | 489 | 490 | 1 491 | 492 | 493 | 1 494 | 495 | 496 | 1 497 | 498 | 499 | 500 | 501 | 1 502 | 503 | 504 | 1 505 | 506 | 507 | 1 508 | 509 | 510 | 511 | 512 | 1 513 | 514 | 515 | 1 516 | 517 | 518 | 1 519 | 520 | 521 | 522 | 523 | 1 524 | 525 | 526 | 1 527 | 528 | 529 | 1 530 | 531 | 532 | 533 | 534 | 1 535 | 536 | 537 | 538 | 539 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 540 | 1 541 | 542 | 543 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 544 | 1 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 1 553 | 554 | 555 | 1 556 | 557 | 558 | 1 559 | 560 | 561 | 562 | 563 | 564 | 565 | Contents\Resources 566 | 1 567 | 568 | 569 | 570 | 571 | library\lib\armeabi-v7a 572 | 1 573 | 574 | 575 | 1 576 | 577 | 578 | 1 579 | 580 | 581 | 1 582 | 583 | 584 | 1 585 | 586 | 587 | 1 588 | 589 | 590 | 0 591 | 592 | 593 | 594 | 595 | 1 596 | 597 | 598 | 1 599 | 600 | 601 | 602 | 603 | Assets 604 | 1 605 | 606 | 607 | Assets 608 | 1 609 | 610 | 611 | 612 | 613 | Assets 614 | 1 615 | 616 | 617 | Assets 618 | 1 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | True 632 | True 633 | 634 | 635 | 12 636 | 637 | 638 | 639 | 640 |
641 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/cpp/server/RADServerC.cpp: -------------------------------------------------------------------------------- 1 | // EMS Package 2 | //--------------------------------------------------------------------------- 3 | 4 | #include 5 | #pragma hdrstop 6 | USEFORM("moduleMain.cpp", EmployeesResource1); /* TDataModule: File Type */ 7 | //--------------------------------------------------------------------------- 8 | #pragma package(smart_init) 9 | //--------------------------------------------------------------------------- 10 | 11 | // Package source. 12 | //--------------------------------------------------------------------------- 13 | 14 | 15 | #pragma argsused 16 | extern "C" int _libmain(unsigned long reason) 17 | { 18 | return 1; 19 | } 20 | //--------------------------------------------------------------------------- 21 | 22 | 23 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/cpp/server/moduleMain.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | #pragma hdrstop 3 | 4 | #include "moduleMain.h" 5 | #include 6 | //--------------------------------------------------------------------------- 7 | #pragma package(smart_init) 8 | #pragma classgroup "System.Classes.TPersistent" 9 | #pragma resource "*.dfm" 10 | //--------------------------------------------------------------------------- 11 | __fastcall TEmployeesResource1::TEmployeesResource1(TComponent* Owner) 12 | : TDataModule(Owner) 13 | { 14 | } 15 | 16 | void TEmployeesResource1::Get(TEndpointContext* AContext, TEndpointRequest* ARequest, TEndpointResponse* AResponse) 17 | { 18 | // Put results in a JSON object... 19 | qry->Active = true; 20 | if (qry->Active) { 21 | if (qry->RecordCount>0) { 22 | TJSONArray* a = new TJSONArray(); 23 | qry->First(); 24 | while (!qry->Eof) { 25 | TJSONObject* o = new TJSONObject(); 26 | o->AddPair("EmployeeNumber", (TJSONValue*) new TJSONNumber( qry->FieldByName("EMP_NO")->AsInteger )); 27 | o->AddPair("FirstName",qry->FieldByName("FIRST_NAME")->AsString ); 28 | o->AddPair("LastName",qry->FieldByName("LAST_NAME")->AsString ); 29 | o->AddPair("PhoneExt",qry->FieldByName("PHONE_EXT")->AsString ); 30 | o->AddPair("HireDate",qry->FieldByName("HIRE_DATE")->AsString ); 31 | o->AddPair("DepartmentNumber", (TJSONValue*) new TJSONNumber( qry->FieldByName("DEPT_NO")->AsInteger )); 32 | o->AddPair("JobCode",qry->FieldByName("JOB_CODE")->AsString ); 33 | o->AddPair("JobGrade",qry->FieldByName("JOB_GRADE")->AsString ); 34 | o->AddPair("JobCountry", qry->FieldByName("JOB_COUNTRY")->AsString ); 35 | o->AddPair("Salary", (TJSONValue*) new TJSONNumber( qry->FieldByName("SALARY")->AsFloat ) ); 36 | a->AddElement(o); 37 | qry->Next(); 38 | } 39 | AResponse->Body->SetValue( a, TRUE ); 40 | } 41 | } 42 | } 43 | 44 | void TEmployeesResource1::GetItem(TEndpointContext* AContext, TEndpointRequest* ARequest, TEndpointResponse* AResponse) 45 | { 46 | qry->SQL->Text = "select * from employee where EMP_NO = :item"; 47 | qry->Params->ParamByName("item")->AsString = ARequest->Params->Values["item"]; 48 | 49 | qry->Active = true; 50 | if (qry->Active) { 51 | if (qry->RecordCount>0) { 52 | qry->First(); 53 | TJSONObject* o = new TJSONObject(); 54 | o->AddPair("EmployeeNumber", (TJSONValue*) new TJSONNumber( qry->FieldByName("EMP_NO")->AsInteger )); 55 | o->AddPair("FirstName",qry->FieldByName("FIRST_NAME")->AsString ); 56 | o->AddPair("LastName",qry->FieldByName("LAST_NAME")->AsString ); 57 | o->AddPair("PhoneExt",qry->FieldByName("PHONE_EXT")->AsString ); 58 | o->AddPair("HireDate",qry->FieldByName("HIRE_DATE")->AsString ); 59 | o->AddPair("DepartmentNumber", (TJSONValue*) new TJSONNumber( qry->FieldByName("DEPT_NO")->AsInteger )); 60 | o->AddPair("JobCode",qry->FieldByName("JOB_CODE")->AsString ); 61 | o->AddPair("JobGrade",qry->FieldByName("JOB_GRADE")->AsString ); 62 | o->AddPair("JobCountry", qry->FieldByName("JOB_COUNTRY")->AsString ); 63 | o->AddPair("Salary", (TJSONValue*) new TJSONNumber( qry->FieldByName("SALARY")->AsFloat ) ); 64 | AResponse->Body->SetValue( o, TRUE ); 65 | } 66 | } 67 | } 68 | 69 | void TEmployeesResource1::Post(TEndpointContext* AContext, TEndpointRequest* ARequest, TEndpointResponse* AResponse) 70 | { 71 | // Parse the JSON 72 | TJSONObject* RequestObject = (TJSONObject*) ARequest->Body->GetValue(); 73 | 74 | // Insert New Record 75 | qry->SQL->Clear(); 76 | qry->SQL->Add("insert into employee ( "); 77 | qry->SQL->Add(" FIRST_NAME, "); 78 | qry->SQL->Add(" LAST_NAME, "); 79 | qry->SQL->Add(" PHONE_EXT, "); 80 | qry->SQL->Add(" HIRE_DATE, "); 81 | qry->SQL->Add(" DEPT_NO, "); 82 | qry->SQL->Add(" JOB_CODE, "); 83 | qry->SQL->Add(" JOB_GRADE, "); 84 | qry->SQL->Add(" JOB_COUNTRY, "); 85 | qry->SQL->Add(" SALARY ) values( "); 86 | qry->SQL->Add(" :FIRST_NAME, "); 87 | qry->SQL->Add(" :LAST_NAME, "); 88 | qry->SQL->Add(" :PHONE_EXT, "); 89 | qry->SQL->Add(" :HIRE_DATE, "); 90 | qry->SQL->Add(" :DEPT_NO, "); 91 | qry->SQL->Add(" :JOB_CODE, "); 92 | qry->SQL->Add(" :JOB_GRADE, "); 93 | qry->SQL->Add(" :JOB_COUNTRY, "); 94 | qry->SQL->Add(" :SALARY);"); 95 | 96 | // Set query parameters. 97 | qry->Params->ParamByName("FIRST_NAME")->AsString = RequestObject->GetValue("FirstName")->Value(); 98 | qry->Params->ParamByName("LAST_NAME")->AsString = RequestObject->GetValue("LastName")->Value(); 99 | qry->Params->ParamByName("PHONE_EXT")->AsString = RequestObject->GetValue("PhoneExt")->Value(); 100 | qry->Params->ParamByName("HIRE_DATE")->AsDateTime = StrToDateTime(RequestObject->GetValue("HireDate")->Value()); 101 | qry->Params->ParamByName("DEPT_NO")->AsInteger = StrToInt(RequestObject->GetValue("DepartmentNumber")->Value()); 102 | qry->Params->ParamByName("JOB_CODE")->AsString = RequestObject->GetValue("JobCode")->Value(); 103 | qry->Params->ParamByName("JOB_GRADE")->AsInteger = StrToInt(RequestObject->GetValue("JobGrade")->Value()); 104 | qry->Params->ParamByName("JOB_COUNTRY")->AsString = RequestObject->GetValue("JobCountry")->Value(); 105 | qry->Params->ParamByName("SALARY")->AsFloat = StrToFloat(RequestObject->GetValue("Salary")->Value()); 106 | 107 | // Execute SQL 108 | qry->ExecSQL(); 109 | 110 | // Get new record ID from Generator. 111 | qry->SQL->Text = "select GEN_ID(EMP_NO_GEN,0) as ID from RDB$DATABASE;"; 112 | qry->Active = True; 113 | qry->First(); 114 | int NewRecordID = qry->Fields->FieldByName("ID")->AsInteger; 115 | qry->Active = False; 116 | 117 | // Send response 118 | TJSONObject* o = new TJSONObject(); 119 | o->AddPair("EmployeeNumber",(TJSONValue*) new TJSONNumber(NewRecordID)); 120 | AResponse->Body->SetValue(o,TRUE); 121 | } 122 | 123 | void TEmployeesResource1::PutItem(TEndpointContext* AContext, TEndpointRequest* ARequest, TEndpointResponse* AResponse) 124 | { 125 | int EmployeeNumber = StrToInt(ARequest->Params->Values["item"]); 126 | 127 | // Parse the JSON 128 | TJSONObject* RequestObject = (TJSONObject*) ARequest->Body->GetValue(); 129 | 130 | // Insert New Record 131 | qry->SQL->Clear(); 132 | qry->SQL->Add(" update employee SET "); 133 | qry->SQL->Add(" FIRST_NAME = :FIRST_NAME, "); 134 | qry->SQL->Add(" LAST_NAME = :LAST_NAME, "); 135 | qry->SQL->Add(" PHONE_EXT = :PHONE_EXT, "); 136 | qry->SQL->Add(" HIRE_DATE = :HIRE_DATE, "); 137 | qry->SQL->Add(" DEPT_NO = :DEPT_NO, "); 138 | qry->SQL->Add(" JOB_CODE = :JOB_CODE, "); 139 | qry->SQL->Add(" JOB_GRADE = :JOB_GRADE, "); 140 | qry->SQL->Add(" JOB_COUNTRY = :JOB_COUNTRY, "); 141 | qry->SQL->Add(" SALARY = :SALARY "); 142 | qry->SQL->Add(" WHERE EMP_NO = :EMP_NO; "); 143 | 144 | // Set query parameters. 145 | qry->Params->ParamByName("EMP_NO")->AsInteger = EmployeeNumber; 146 | qry->Params->ParamByName("FIRST_NAME")->AsString = RequestObject->GetValue("FirstName")->Value(); 147 | qry->Params->ParamByName("LAST_NAME")->AsString = RequestObject->GetValue("LastName")->Value(); 148 | qry->Params->ParamByName("PHONE_EXT")->AsString = RequestObject->GetValue("PhoneExt")->Value(); 149 | qry->Params->ParamByName("HIRE_DATE")->AsDateTime = StrToDateTime(RequestObject->GetValue("HireDate")->Value()); 150 | qry->Params->ParamByName("DEPT_NO")->AsInteger = StrToInt(RequestObject->GetValue("DepartmentNumber")->Value()); 151 | qry->Params->ParamByName("JOB_CODE")->AsString = RequestObject->GetValue("JobCode")->Value(); 152 | qry->Params->ParamByName("JOB_GRADE")->AsInteger = StrToInt(RequestObject->GetValue("JobGrade")->Value()); 153 | qry->Params->ParamByName("JOB_COUNTRY")->AsString = RequestObject->GetValue("JobCountry")->Value(); 154 | qry->Params->ParamByName("SALARY")->AsFloat = StrToFloat(RequestObject->GetValue("Salary")->Value()); 155 | 156 | // Execute SQL 157 | qry->ExecSQL(); 158 | 159 | // Build the JSON response. 160 | TJSONObject* o = new TJSONObject(); 161 | o->AddPair("EmployeeNumber",(TJSONValue*) new TJSONNumber(EmployeeNumber)); 162 | AResponse->Body->SetValue(o,TRUE); 163 | } 164 | 165 | void TEmployeesResource1::DeleteItem(TEndpointContext* AContext, TEndpointRequest* ARequest, TEndpointResponse* AResponse) 166 | { 167 | // Get employee number parameter 168 | int EmployeeNumber = StrToInt(ARequest->Params->Values["item"]); 169 | 170 | // Insert New Record 171 | qry->SQL->Text = "DELETE FROM employee WHERE EMP_NO = :EMP_NO; "; 172 | 173 | // Set query parameters. 174 | qry->Params->ParamByName("EMP_NO")->AsInteger = EmployeeNumber; 175 | 176 | // Execute SQL 177 | qry->ExecSQL(); 178 | 179 | // Build the JSON response. 180 | TJSONObject* o = new TJSONObject(); 181 | o->AddPair("EmployeeNumber",(TJSONValue*) new TJSONNumber(EmployeeNumber)); 182 | AResponse->Body->SetValue(o,TRUE); 183 | } 184 | 185 | static void Register() 186 | { 187 | std::auto_ptr attributes(new TEMSResourceAttributes()); 188 | attributes->ResourceName = "employees"; 189 | attributes->ResourceSuffix["GetItem"] = "{item}"; 190 | attributes->ResourceSuffix["PutItem"] = "{item}"; 191 | attributes->ResourceSuffix["DeleteItem"] = "{item}"; 192 | RegisterResource(__typeinfo(TEmployeesResource1), attributes.release()); 193 | } 194 | 195 | #pragma startup Register 32 196 | 197 | 198 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/cpp/server/moduleMain.dfm: -------------------------------------------------------------------------------- 1 | object EmployeesResource1: TEmployeesResource1 2 | OldCreateOrder = False 3 | Height = 150 4 | Width = 215 5 | object conn: TFDConnection 6 | Params.Strings = ( 7 | 'ConnectionDef=EMPLOYEE') 8 | LoginPrompt = False 9 | Left = 45 10 | Top = 15 11 | end 12 | object qry: TFDQuery 13 | Connection = conn 14 | SQL.Strings = ( 15 | 'SELECT * FROM EMPLOYEE') 16 | Left = 45 17 | Top = 63 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/cpp/server/moduleMain.h: -------------------------------------------------------------------------------- 1 | // EMS Resource Modules 2 | //--------------------------------------------------------------------------- 3 | 4 | #ifndef moduleMainH 5 | #define moduleMainH 6 | //--------------------------------------------------------------------------- 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | //--------------------------------------------------------------------------- 32 | #pragma explicit_rtti methods (public) 33 | class TEmployeesResource1 : public TDataModule 34 | { 35 | __published: 36 | TFDConnection *conn; 37 | TFDQuery *qry; 38 | private: 39 | public: 40 | __fastcall TEmployeesResource1(TComponent* Owner); 41 | void Get(TEndpointContext* AContext, TEndpointRequest* ARequest, TEndpointResponse* AResponse); 42 | void GetItem(TEndpointContext* AContext, TEndpointRequest* ARequest, TEndpointResponse* AResponse); 43 | void Post(TEndpointContext* AContext, TEndpointRequest* ARequest, TEndpointResponse* AResponse); 44 | void PutItem(TEndpointContext* AContext, TEndpointRequest* ARequest, TEndpointResponse* AResponse); 45 | void DeleteItem(TEndpointContext* AContext, TEndpointRequest* ARequest, TEndpointResponse* AResponse); 46 | }; 47 | #endif 48 | 49 | 50 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/delphi/client/EmployeesClientD.dpr: -------------------------------------------------------------------------------- 1 | program EmployeesClientD; 2 | 3 | uses 4 | System.StartUpCopy, 5 | FMX.Forms, 6 | formMain in 'formMain.pas' {frmMain}; 7 | 8 | {$R *.res} 9 | 10 | begin 11 | Application.Initialize; 12 | Application.CreateForm(TfrmMain, frmMain); 13 | Application.Run; 14 | end. 15 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/delphi/client/formMain.fmx: -------------------------------------------------------------------------------- 1 | object frmMain: TfrmMain 2 | Left = 0 3 | Top = 0 4 | Caption = 'Employees Client' 5 | ClientHeight = 399 6 | ClientWidth = 665 7 | FormFactor.Width = 320 8 | FormFactor.Height = 480 9 | FormFactor.Devices = [Desktop] 10 | DesignerMasterStyle = 0 11 | object Panel3: TPanel 12 | Align = Client 13 | Size.Width = 665.000000000000000000 14 | Size.Height = 327.000000000000000000 15 | Size.PlatformDefault = False 16 | TabOrder = 1 17 | object lblFirstName: TLabel 18 | Position.X = 160.000000000000000000 19 | Position.Y = 16.000000000000000000 20 | Text = 'First Name' 21 | end 22 | object lblLastName: TLabel 23 | Position.X = 296.000000000000000000 24 | Position.Y = 16.000000000000000000 25 | Text = 'Last Name' 26 | end 27 | object lblEmployeeNumber: TLabel 28 | Position.X = 16.000000000000000000 29 | Position.Y = 16.000000000000000000 30 | Text = 'Employee Number' 31 | end 32 | object lblPhoneExt: TLabel 33 | Position.X = 424.000000000000000000 34 | Position.Y = 16.000000000000000000 35 | Text = 'Phone Extension' 36 | end 37 | object lblHireDate: TLabel 38 | Position.X = 16.000000000000000000 39 | Position.Y = 64.000000000000000000 40 | Size.Width = 81.000000000000000000 41 | Size.Height = 17.000000000000000000 42 | Size.PlatformDefault = False 43 | Text = 'Hire Date' 44 | end 45 | object lblDepartmentNumber: TLabel 46 | Position.X = 160.000000000000000000 47 | Position.Y = 64.000000000000000000 48 | Size.Width = 145.000000000000000000 49 | Size.Height = 17.000000000000000000 50 | Size.PlatformDefault = False 51 | Text = 'Department Number' 52 | end 53 | object lblJobCode: TLabel 54 | Position.X = 16.000000000000000000 55 | Position.Y = 112.000000000000000000 56 | Size.Width = 81.000000000000000000 57 | Size.Height = 17.000000000000000000 58 | Size.PlatformDefault = False 59 | Text = 'Job Code' 60 | end 61 | object lblJobGrade: TLabel 62 | Position.X = 160.000000000000000000 63 | Position.Y = 112.000000000000000000 64 | Size.Width = 81.000000000000000000 65 | Size.Height = 17.000000000000000000 66 | Size.PlatformDefault = False 67 | Text = 'Job Grade' 68 | end 69 | object lblJobCountry: TLabel 70 | Position.X = 304.000000000000000000 71 | Position.Y = 112.000000000000000000 72 | Size.Width = 81.000000000000000000 73 | Size.Height = 17.000000000000000000 74 | Size.PlatformDefault = False 75 | Text = 'Job Country' 76 | end 77 | object lblSalary: TLabel 78 | Position.X = 16.000000000000000000 79 | Position.Y = 160.000000000000000000 80 | Size.Width = 81.000000000000000000 81 | Size.Height = 17.000000000000000000 82 | Size.PlatformDefault = False 83 | Text = 'Salary' 84 | end 85 | object edFirstName: TEdit 86 | Touch.InteractiveGestures = [LongTap, DoubleTap] 87 | TabOrder = 3 88 | ReadOnly = True 89 | Position.X = 160.000000000000000000 90 | Position.Y = 32.000000000000000000 91 | Size.Width = 121.000000000000000000 92 | Size.Height = 22.000000000000000000 93 | Size.PlatformDefault = False 94 | StyledSettings = [Family, Size, Style] 95 | end 96 | object edLastName: TEdit 97 | Touch.InteractiveGestures = [LongTap, DoubleTap] 98 | TabOrder = 4 99 | ReadOnly = True 100 | Position.X = 296.000000000000000000 101 | Position.Y = 32.000000000000000000 102 | Size.Width = 113.000000000000000000 103 | Size.Height = 22.000000000000000000 104 | Size.PlatformDefault = False 105 | StyledSettings = [Family, Size, Style] 106 | end 107 | object edtPhoneExt: TEdit 108 | Touch.InteractiveGestures = [LongTap, DoubleTap] 109 | TabOrder = 5 110 | ReadOnly = True 111 | Position.X = 424.000000000000000000 112 | Position.Y = 32.000000000000000000 113 | StyledSettings = [Family, Size, Style] 114 | end 115 | object edtJobCode: TEdit 116 | Touch.InteractiveGestures = [LongTap, DoubleTap] 117 | TabOrder = 8 118 | ReadOnly = True 119 | Position.X = 16.000000000000000000 120 | Position.Y = 128.000000000000000000 121 | Size.Width = 121.000000000000000000 122 | Size.Height = 22.000000000000000000 123 | Size.PlatformDefault = False 124 | StyledSettings = [Family, Size, Style] 125 | end 126 | object edtJobGrade: TEdit 127 | Touch.InteractiveGestures = [LongTap, DoubleTap] 128 | TabOrder = 9 129 | ReadOnly = True 130 | Position.X = 160.000000000000000000 131 | Position.Y = 128.000000000000000000 132 | Size.Width = 121.000000000000000000 133 | Size.Height = 22.000000000000000000 134 | Size.PlatformDefault = False 135 | StyledSettings = [Family, Size, Style] 136 | end 137 | object edtJobCountry: TEdit 138 | Touch.InteractiveGestures = [LongTap, DoubleTap] 139 | TabOrder = 10 140 | ReadOnly = True 141 | Position.X = 304.000000000000000000 142 | Position.Y = 128.000000000000000000 143 | Size.Width = 113.000000000000000000 144 | Size.Height = 22.000000000000000000 145 | Size.PlatformDefault = False 146 | StyledSettings = [Family, Size, Style] 147 | end 148 | object spedEmployeeNumber: TSpinBox 149 | Touch.InteractiveGestures = [LongTap, DoubleTap] 150 | TabOrder = 2 151 | Cursor = crIBeam 152 | Max = 10000.000000000000000000 153 | ReadOnly = True 154 | Position.X = 16.000000000000000000 155 | Position.Y = 32.000000000000000000 156 | Enabled = False 157 | Size.Width = 121.000000000000000000 158 | Size.Height = 22.000000000000000000 159 | Size.PlatformDefault = False 160 | end 161 | object spedDepartmentNumber: TSpinBox 162 | Touch.InteractiveGestures = [LongTap, DoubleTap] 163 | TabOrder = 7 164 | Cursor = crIBeam 165 | Max = 10000.000000000000000000 166 | ReadOnly = True 167 | Position.X = 160.000000000000000000 168 | Position.Y = 80.000000000000000000 169 | Size.Width = 121.000000000000000000 170 | Size.Height = 22.000000000000000000 171 | Size.PlatformDefault = False 172 | StyledSettings = [Family, Size, Style] 173 | end 174 | object dtedHireDate: TDateEdit 175 | Date = 39445.000000000000000000 176 | Position.X = 16.000000000000000000 177 | Position.Y = 80.000000000000000000 178 | ReadOnly = True 179 | Size.Width = 121.000000000000000000 180 | Size.Height = 22.000000000000000000 181 | Size.PlatformDefault = False 182 | StyledSettings = [Family, Size, Style] 183 | TabOrder = 6 184 | end 185 | object Panel1: TPanel 186 | Align = Bottom 187 | Position.Y = 260.000000000000000000 188 | Size.Width = 665.000000000000000000 189 | Size.Height = 67.000000000000000000 190 | Size.PlatformDefault = False 191 | TabOrder = 12 192 | object btnPrev: TButton 193 | Position.X = 96.000000000000000000 194 | Position.Y = 8.000000000000000000 195 | TabOrder = 1 196 | Text = 'Prev' 197 | OnClick = btnPrevClick 198 | end 199 | object btnNext: TButton 200 | Position.X = 184.000000000000000000 201 | Position.Y = 8.000000000000000000 202 | TabOrder = 0 203 | Text = 'Next' 204 | OnClick = btnNextClick 205 | end 206 | object btnRead: TButton 207 | Position.X = 8.000000000000000000 208 | Position.Y = 8.000000000000000000 209 | TabOrder = 2 210 | Text = 'Read' 211 | OnClick = btnReadClick 212 | end 213 | object btnCreate: TButton 214 | Position.X = 8.000000000000000000 215 | Position.Y = 40.000000000000000000 216 | TabOrder = 3 217 | Text = 'Create' 218 | OnClick = btnCreateClick 219 | end 220 | object btnCommit: TButton 221 | Enabled = False 222 | Position.X = 96.000000000000000000 223 | Position.Y = 40.000000000000000000 224 | TabOrder = 4 225 | Text = 'Commit' 226 | OnClick = btnCommitClick 227 | end 228 | object btnEdit: TButton 229 | Position.X = 184.000000000000000000 230 | Position.Y = 40.000000000000000000 231 | TabOrder = 5 232 | Text = 'Edit' 233 | OnClick = btnEditClick 234 | end 235 | object btnUpdate: TButton 236 | Enabled = False 237 | Position.X = 272.000000000000000000 238 | Position.Y = 40.000000000000000000 239 | TabOrder = 6 240 | Text = 'Update' 241 | OnClick = btnUpdateClick 242 | end 243 | object btnDelete: TButton 244 | Position.X = 360.000000000000000000 245 | Position.Y = 40.000000000000000000 246 | TabOrder = 7 247 | Text = 'Delete' 248 | OnClick = btnDeleteClick 249 | end 250 | object btnFirst: TButton 251 | Position.X = 272.000000000000000000 252 | Position.Y = 8.000000000000000000 253 | TabOrder = 8 254 | Text = 'First' 255 | OnClick = btnFirstClick 256 | end 257 | object btnLast: TButton 258 | Position.X = 360.000000000000000000 259 | Position.Y = 9.000000000000000000 260 | TabOrder = 25 261 | Text = 'Last' 262 | OnClick = btnLastClick 263 | end 264 | end 265 | object spedSalary: TSpinBox 266 | Touch.InteractiveGestures = [LongTap, DoubleTap] 267 | TabOrder = 11 268 | Cursor = crIBeam 269 | Max = 1000000.000000000000000000 270 | ValueType = Float 271 | Increment = 1000.000000000000000000 272 | ReadOnly = True 273 | Position.X = 16.000000000000000000 274 | Position.Y = 176.000000000000000000 275 | Size.Width = 169.000000000000000000 276 | Size.Height = 22.000000000000000000 277 | Size.PlatformDefault = False 278 | StyledSettings = [Family, Size, Style] 279 | end 280 | end 281 | object Panel2: TPanel 282 | Align = Bottom 283 | Position.Y = 327.000000000000000000 284 | Size.Width = 665.000000000000000000 285 | Size.Height = 72.000000000000000000 286 | Size.PlatformDefault = False 287 | TabOrder = 20 288 | end 289 | object RESTClient: TRESTClient 290 | Accept = 'application/json, text/plain; q=0.9, text/html;q=0.8,' 291 | AcceptCharset = 'UTF-8, *;q=0.8' 292 | BaseURL = 'http://127.0.0.1:8080/' 293 | Params = <> 294 | HandleRedirects = True 295 | Left = 24 296 | Top = 336 297 | end 298 | object RESTRequest: TRESTRequest 299 | Client = RESTClient 300 | Params = <> 301 | Resource = 'employees' 302 | Response = RESTResponse 303 | SynchronizedEvents = False 304 | Left = 104 305 | Top = 336 306 | end 307 | object RESTResponse: TRESTResponse 308 | ContentType = 'application/json' 309 | Left = 192 310 | Top = 336 311 | end 312 | end 313 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/delphi/client/formMain.pas: -------------------------------------------------------------------------------- 1 | unit formMain; 2 | 3 | interface 4 | 5 | uses 6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, 7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Rtti, 8 | IPPeerClient, Data.DB, Datasnap.DBClient, REST.Response.Adapter, REST.Client, 9 | Data.Bind.Components, Data.Bind.ObjectScope, FMX.Layouts, FMX.Grid, 10 | FMX.Controls.Presentation, FMX.StdCtrls, FMX.TabControl, Data.Bind.EngExt, 11 | Fmx.Bind.DBEngExt, Fmx.Bind.Grid, System.Bindings.Outputs, Fmx.Bind.Editors, 12 | Data.Bind.Grid, Data.Bind.DBScope, Data.Bind.Controls, Fmx.Bind.Navigator, 13 | FMX.DateTimeCtrls, FMX.EditBox, FMX.SpinBox, FMX.Edit, 14 | System.JSON; 15 | 16 | type 17 | TfrmMain = class(TForm) 18 | RESTClient: TRESTClient; 19 | RESTRequest: TRESTRequest; 20 | RESTResponse: TRESTResponse; 21 | Panel3: TPanel; 22 | lblFirstName: TLabel; 23 | lblLastName: TLabel; 24 | lblEmployeeNumber: TLabel; 25 | lblPhoneExt: TLabel; 26 | lblHireDate: TLabel; 27 | lblDepartmentNumber: TLabel; 28 | lblJobCode: TLabel; 29 | lblJobGrade: TLabel; 30 | lblJobCountry: TLabel; 31 | lblSalary: TLabel; 32 | edFirstName: TEdit; 33 | edLastName: TEdit; 34 | edtPhoneExt: TEdit; 35 | edtJobCode: TEdit; 36 | edtJobGrade: TEdit; 37 | edtJobCountry: TEdit; 38 | spedEmployeeNumber: TSpinBox; 39 | spedDepartmentNumber: TSpinBox; 40 | dtedHireDate: TDateEdit; 41 | Panel1: TPanel; 42 | Panel2: TPanel; 43 | btnPrev: TButton; 44 | btnNext: TButton; 45 | btnRead: TButton; 46 | btnCreate: TButton; 47 | btnCommit: TButton; 48 | btnEdit: TButton; 49 | btnUpdate: TButton; 50 | btnDelete: TButton; 51 | btnFirst: TButton; 52 | btnLast: TButton; 53 | spedSalary: TSpinBox; 54 | procedure btnReadClick(Sender: TObject); 55 | procedure btnPrevClick(Sender: TObject); 56 | procedure btnNextClick(Sender: TObject); 57 | procedure btnCreateClick(Sender: TObject); 58 | procedure btnCommitClick(Sender: TObject); 59 | procedure btnFirstClick(Sender: TObject); 60 | procedure btnLastClick(Sender: TObject); 61 | procedure btnEditClick(Sender: TObject); 62 | procedure btnUpdateClick(Sender: TObject); 63 | procedure btnDeleteClick(Sender: TObject); 64 | private 65 | fJSONArray: TJSONArray; 66 | fCurrentIndex: int32; 67 | private 68 | procedure JSONToForm; 69 | procedure ClearForm; 70 | procedure CreateMode; 71 | procedure BrowseMode; 72 | procedure EditMode; 73 | public 74 | { Public declarations } 75 | end; 76 | 77 | var 78 | frmMain: TfrmMain; 79 | 80 | implementation 81 | uses 82 | strutils, 83 | REST.Types; 84 | 85 | {$R *.fmx} 86 | 87 | procedure TfrmMain.ClearForm; 88 | begin 89 | spedEmployeeNumber.Value := 0; 90 | edFirstName.Text := ''; 91 | edLastName.Text := ''; 92 | edtPhoneExt.Text := ''; 93 | spedDepartmentNumber.Value := 0; 94 | edtJobCode.Text := ''; 95 | edtJobGrade.Text := ''; 96 | edtJobCountry.Text := ''; 97 | spedSalary.Value := 0.0; 98 | dtedHireDate.DateTime := Now; 99 | end; 100 | 101 | procedure TfrmMain.btnCommitClick(Sender: TObject); 102 | begin 103 | //- Prepare to POST data to 'employees' end-point. 104 | RESTRequest.Resource := 'employees'; 105 | RESTRequest.Method := TRESTRequestMethod.rmPOST; 106 | RESTRequest.Response := RESTResponse; 107 | 108 | //- Populate the JSON resource to post. 109 | RESTRequest.Body.ClearBody; 110 | with RESTRequest.Body.JSONWriter do begin 111 | WriteStartObject; 112 | WritePropertyName('FirstName'); 113 | WriteValue(edFirstName.Text); 114 | WritePropertyName('LastName'); 115 | WriteValue(edLastName.Text); 116 | WritePropertyName('PhoneExt'); 117 | WriteValue(edtPhoneExt.Text); 118 | WritePropertyName('DepartmentNumber'); 119 | WriteValue(spedDepartmentNumber.Value); 120 | WritePropertyName('JobCode'); 121 | WriteValue(edtJobCode.Text); 122 | WritePropertyName('JobGrade'); 123 | WriteValue(edtJobGrade.Text); 124 | WritePropertyName('JobCountry'); 125 | WriteValue(edtJobCountry.Text); 126 | WritePropertyName('Salary'); 127 | WriteValue(spedSalary.Value); 128 | WritePropertyName('HireDate'); 129 | WriteValue(FormatDateTime('MM/DD/YYYY 00:00:00',dtedHireDate.DateTime)); 130 | WriteEnd; 131 | end; 132 | 133 | // Adjust the form to recieve the result. 134 | BrowseMode; 135 | 136 | // Execute the request 137 | RESTRequest.Execute; 138 | 139 | //- Re-read 140 | btnReadClick(Sender); 141 | 142 | end; 143 | 144 | procedure TfrmMain.JSONToForm; 145 | var 146 | O: TJSONObject; 147 | begin 148 | ClearForm; 149 | if fJSONArray.Count>0 then begin 150 | O := fJSONArray.Items[fCurrentIndex] as TJSONObject; 151 | spedEmployeeNumber.Value := StrToInt( o.GetValue('EmployeeNumber').ToString ); 152 | edFirstName.Text := o.GetValue('FirstName').Value; 153 | edLastName.Text := o.GetValue('LastName').Value; 154 | if assigned(o.GetValue('PhoneExt')) then begin 155 | edtPhoneExt.Text := o.GetValue('PhoneExt').Value; 156 | end; 157 | spedDepartmentNumber.Value := StrToFloat( o.GetValue('DepartmentNumber').Value ); 158 | edtJobCode.Text := o.GetValue('JobCode').Value; 159 | edtJobGrade.Text := o.GetValue('JobGrade').Value; 160 | edtJobCountry.Text := o.GetValue('JobCountry').Value; 161 | spedSalary.Text := o.GetValue('Salary').Value; 162 | dtedHireDate.DateTime := StrToDateTime( o.GetValue('HireDate').Value ); 163 | end; 164 | end; 165 | 166 | procedure TfrmMain.CreateMode; 167 | begin 168 | // Read Only 169 | edFirstName.ReadOnly := False; 170 | edLastName.ReadOnly := False; 171 | edtPhoneExt.ReadOnly := False; 172 | edtJobCode.ReadOnly := False; 173 | edtJobGrade.ReadOnly := False; 174 | spedSalary.ReadOnly := False; 175 | edtJobCountry.ReadOnly := False; 176 | dtedHireDate.ReadOnly := False; 177 | // Text Prompt 178 | edFirstName.TextPrompt := 'First Name'; 179 | edLastName.TextPrompt := 'Last Name'; 180 | edtPhoneExt.TextPrompt := 'Phone Ext'; 181 | spedDepartmentNumber.TextPrompt := 'Dept No'; 182 | spedDepartmentNumber.ReadOnly := False; 183 | edtJobCode.TextPrompt := 'Job Code'; 184 | edtJobGrade.TextPrompt := 'Job Grade'; 185 | edtJobCountry.TextPrompt := 'Job Country'; 186 | spedSalary.TextPrompt := '0.0'; 187 | // Text Color 188 | edFirstName.TextSettings.FontColor := TAlphaColorRec.Red; 189 | edLastName.TextSettings.FontColor := TAlphaColorRec.Red; 190 | edtPhoneExt.TextSettings.FontColor := TAlphaColorRec.Red; 191 | spedDepartmentNumber.TextSettings.FontColor := TAlphaColorRec.Red; 192 | edtJobCode.TextSettings.FontColor := TAlphaColorRec.Red; 193 | edtJobGrade.TextSettings.FontColor := TAlphaColorRec.Red; 194 | edtJobCountry.TextSettings.FontColor := TAlphaColorRec.Red; 195 | spedSalary.TextSettings.FontColor := TAlphaColorRec.Red; 196 | dtedHireDate.TextSettings.FontColor := TAlphaColorRec.Red; 197 | // adjust buttons 198 | btnRead.Enabled := False; 199 | btnNext.Enabled := False; 200 | btnPrev.Enabled := False; 201 | btnLast.Enabled := False; 202 | btnFirst.Enabled := False; 203 | btnCreate.Enabled := False; 204 | btnCommit.Enabled := True; 205 | btnEdit.Enabled := False; 206 | btnUpdate.Enabled := False; 207 | btnDelete.Enabled := False; 208 | end; 209 | 210 | procedure TfrmMain.EditMode; 211 | begin 212 | // Read Only 213 | edFirstName.ReadOnly := False; 214 | edLastName.ReadOnly := False; 215 | edtPhoneExt.ReadOnly := False; 216 | edtJobCode.ReadOnly := False; 217 | edtJobGrade.ReadOnly := False; 218 | edtJobCountry.ReadOnly := False; 219 | spedDepartmentNumber.ReadOnly := False; 220 | spedSalary.ReadOnly := False; 221 | dtedHireDate.ReadOnly := False; 222 | // Text Prompt 223 | edFirstName.TextPrompt := 'First Name'; 224 | edLastName.TextPrompt := 'Last Name'; 225 | edtPhoneExt.TextPrompt := 'Phone Ext'; 226 | spedDepartmentNumber.TextPrompt := 'Dept No'; 227 | edtJobCode.TextPrompt := 'Job Code'; 228 | edtJobGrade.TextPrompt := 'Job Grade'; 229 | edtJobCountry.TextPrompt := 'Job Country'; 230 | spedSalary.TextPrompt := 'Salary'; 231 | // Text Color 232 | edFirstName.TextSettings.FontColor := TAlphaColorRec.Blue; 233 | edLastName.TextSettings.FontColor := TAlphaColorRec.Blue; 234 | edtPhoneExt.TextSettings.FontColor := TAlphaColorRec.Blue; 235 | spedDepartmentNumber.TextSettings.FontColor := TAlphaColorRec.Blue; 236 | edtJobCode.TextSettings.FontColor := TAlphaColorRec.Blue; 237 | edtJobGrade.TextSettings.FontColor := TAlphaColorRec.Blue; 238 | edtJobCountry.TextSettings.FontColor := TAlphaColorRec.Blue; 239 | spedSalary.TextSettings.FontColor := TAlphaColorRec.Blue; 240 | dtedHireDate.TextSettings.FontColor := TAlphaColorRec.Blue; 241 | // adjust buttons 242 | btnRead.Enabled := False; 243 | btnNext.Enabled := False; 244 | btnPrev.Enabled := False; 245 | btnLast.Enabled := False; 246 | btnFirst.Enabled := False; 247 | btnCreate.Enabled := False; 248 | btnCommit.Enabled := False; 249 | btnEdit.Enabled := False; 250 | btnUpdate.Enabled := True; 251 | btnDelete.Enabled := False; 252 | end; 253 | 254 | procedure TfrmMain.BrowseMode; 255 | begin 256 | spedEmployeeNumber.Enabled := True; 257 | // Read only 258 | edFirstName.ReadOnly := True; 259 | edLastName.ReadOnly := True; 260 | edtPhoneExt.ReadOnly := True; 261 | edtJobCode.ReadOnly := True; 262 | edtJobGrade.ReadOnly := True; 263 | edtJobCountry.ReadOnly := True; 264 | spedSalary.ReadOnly := True; 265 | spedDepartmentNumber.ReadOnly := True; 266 | dtedHireDate.ReadOnly := True; 267 | // Text prompt 268 | edFirstName.TextPrompt := ''; 269 | edLastName.TextPrompt := ''; 270 | edtPhoneExt.TextPrompt := ''; 271 | spedDepartmentNumber.TextPrompt := ''; 272 | edtJobCode.TextPrompt := ''; 273 | edtJobGrade.TextPrompt := ''; 274 | edtJobCountry.TextPrompt := ''; 275 | spedSalary.TextPrompt := ''; 276 | // Text Color 277 | edFirstName.TextSettings.FontColor := TAlphaColorRec.Black; 278 | edLastName.TextSettings.FontColor := TAlphaColorRec.Black; 279 | edtPhoneExt.TextSettings.FontColor := TAlphaColorRec.Black; 280 | spedDepartmentNumber.TextSettings.FontColor := TAlphaColorRec.Black; 281 | edtJobCode.TextSettings.FontColor := TAlphaColorRec.Black; 282 | edtJobGrade.TextSettings.FontColor := TAlphaColorRec.Black; 283 | edtJobCountry.TextSettings.FontColor := TAlphaColorRec.Black; 284 | spedSalary.TextSettings.FontColor := TAlphaColorRec.Black; 285 | dtedHireDate.TextSettings.FontColor := TAlphaColorRec.Black; 286 | // adjust buttons 287 | btnRead.Enabled := True; 288 | btnNext.Enabled := True; 289 | btnPrev.Enabled := True; 290 | btnLast.Enabled := True; 291 | btnFirst.Enabled := True; 292 | btnCreate.Enabled := True; 293 | btnCommit.Enabled := False; 294 | btnEdit.Enabled := True; 295 | btnUpdate.Enabled := False; 296 | btnDelete.Enabled := True; 297 | end; 298 | 299 | procedure TfrmMain.btnCreateClick(Sender: TObject); 300 | begin 301 | //- Clear the form and adjust text read-only and prompts. 302 | ClearForm; 303 | CreateMode; 304 | end; 305 | 306 | procedure TfrmMain.btnDeleteClick(Sender: TObject); 307 | var 308 | o: TJSONObject; 309 | begin 310 | //- Prepare to DELETE data from 'employees' end-point. 311 | RESTRequest.Resource := 'employees/'+spedEmployeeNumber.Text; 312 | RESTRequest.Method := TRESTRequestMethod.rmDELETE; 313 | RESTRequest.Response := RESTResponse; 314 | 315 | //- Add the employee number as a parameter to the request. 316 | RESTREquest.Params.Clear; 317 | with RESTRequest.Params.AddItem do begin 318 | name := 'EmployeeNumber'; 319 | value := spedEmployeeNumber.Text; 320 | end; 321 | 322 | // Execute the request 323 | RESTRequest.Execute; 324 | 325 | //- Re-read 326 | btnReadClick(Sender); 327 | end; 328 | 329 | procedure TfrmMain.btnEditClick(Sender: TObject); 330 | begin 331 | EditMode; 332 | end; 333 | 334 | procedure TfrmMain.btnFirstClick(Sender: TObject); 335 | begin 336 | fCurrentIndex := 0; 337 | JSONToForm; 338 | end; 339 | 340 | procedure TfrmMain.btnLastClick(Sender: TObject); 341 | begin 342 | if fJSONArray.Count>0 then begin 343 | fCurrentIndex := pred(fJSONArray.Count); 344 | end else begin 345 | fCurrentIndex := 0; 346 | end; 347 | JSONToForm; 348 | end; 349 | 350 | procedure TfrmMain.btnNextClick(Sender: TObject); 351 | begin 352 | if fCurrentIndex0 then begin 361 | dec(fCurrentIndex); 362 | end; 363 | JSONToForm; 364 | end; 365 | 366 | procedure TfrmMain.btnReadClick(Sender: TObject); 367 | var 368 | Param: TRESTRequestParameter; 369 | begin 370 | //- Request data from 'employees' end-point. 371 | RESTRequest.Resource := 'employees'; 372 | RESTRequest.Method := TRESTRequestMethod.rmGet; 373 | RESTRequest.Response := RESTResponse; 374 | 375 | // Make request. 376 | RESTRequest.Execute; 377 | 378 | //- Decode the data into a class global 379 | if assigned(fJSONArray) then begin 380 | fJSONArray.DisposeOf; 381 | end; 382 | fJSONArray := TJSONObject.ParseJSONValue(RESTResponse.Content) as TJSONArray; 383 | 384 | //- set index. 385 | fCurrentIndex := 0; 386 | 387 | //- Load current resource to form. 388 | JSONToForm; 389 | end; 390 | 391 | procedure TfrmMain.btnUpdateClick(Sender: TObject); 392 | begin 393 | //- Prepare to PUT data to 'employees' end-point. 394 | RESTRequest.Resource := 'employees/'+spedEmployeeNumber.Text; 395 | RESTRequest.Method := TRESTRequestMethod.rmPUT; 396 | RESTRequest.Response := RESTResponse; 397 | 398 | //- Populate the JSON resource to post. 399 | RESTRequest.Body.ClearBody; 400 | with RESTRequest.Body.JSONWriter do begin 401 | WriteStartObject; 402 | WritePropertyName('FirstName'); 403 | WriteValue(edFirstName.Text); 404 | WritePropertyName('LastName'); 405 | WriteValue(edLastName.Text); 406 | WritePropertyName('PhoneExt'); 407 | WriteValue(edtPhoneExt.Text); 408 | WritePropertyName('DepartmentNumber'); 409 | WriteValue(spedDepartmentNumber.Value); 410 | WritePropertyName('JobCode'); 411 | WriteValue(edtJobCode.Text); 412 | WritePropertyName('JobGrade'); 413 | WriteValue(edtJobGrade.Text); 414 | WritePropertyName('JobCountry'); 415 | WriteValue(edtJobCountry.Text); 416 | WritePropertyName('Salary'); 417 | WriteValue(spedSalary.Value); 418 | WritePropertyName('HireDate'); 419 | WriteValue(FormatDateTime('MM/DD/YYYY 00:00:00',dtedHireDate.DateTime)); 420 | WriteEnd; 421 | end; 422 | 423 | // Adjust the form to recieve the result. 424 | BrowseMode; 425 | 426 | // Execute the request 427 | RESTRequest.Execute; 428 | 429 | //- Re-read 430 | btnReadClick(Sender); 431 | end; 432 | 433 | end. 434 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/delphi/server/RADServerD.dpk: -------------------------------------------------------------------------------- 1 | package RADServerD; 2 | 3 | {$R *.res} 4 | {$IFDEF IMPLICITBUILDING This IFDEF should not be used by users} 5 | {$ALIGN 8} 6 | {$ASSERTIONS ON} 7 | {$BOOLEVAL OFF} 8 | {$DEBUGINFO OFF} 9 | {$EXTENDEDSYNTAX ON} 10 | {$IMPORTEDDATA ON} 11 | {$IOCHECKS ON} 12 | {$LOCALSYMBOLS ON} 13 | {$LONGSTRINGS ON} 14 | {$OPENSTRINGS ON} 15 | {$OPTIMIZATION OFF} 16 | {$OVERFLOWCHECKS OFF} 17 | {$RANGECHECKS OFF} 18 | {$REFERENCEINFO ON} 19 | {$SAFEDIVIDE OFF} 20 | {$STACKFRAMES ON} 21 | {$TYPEDADDRESS OFF} 22 | {$VARSTRINGCHECKS ON} 23 | {$WRITEABLECONST OFF} 24 | {$MINENUMSIZE 1} 25 | {$IMAGEBASE $400000} 26 | {$DEFINE DEBUG} 27 | {$ENDIF IMPLICITBUILDING} 28 | {$RUNONLY} 29 | {$IMPLICITBUILD ON} 30 | 31 | requires 32 | rtl, 33 | emsserverapi, 34 | dbrtl, 35 | DbxCommonDriver, 36 | dbexpress, 37 | DBXInterBaseDriver, 38 | FireDAC, 39 | FireDACCommonDriver, 40 | FireDACCommon, 41 | FireDACIBDriver; 42 | 43 | contains 44 | moduleMain {EmployeesResource1: TDataModule}; 45 | 46 | end. 47 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/delphi/server/RADServerD.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {477055CA-77A1-4032-8B0A-2C2F8FC13BF5} 4 | RADServerD.dpk 5 | 18.4 6 | None 7 | True 8 | Debug 9 | Win32 10 | 131 11 | Package 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Base 34 | true 35 | 36 | 37 | true 38 | Cfg_1 39 | true 40 | true 41 | 42 | 43 | true 44 | Base 45 | true 46 | 47 | 48 | ..\..\..\out\lib\$(Platform)\$(Config) 49 | .\$(Platform)\$(Config) 50 | false 51 | false 52 | false 53 | false 54 | false 55 | true 56 | true 57 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 58 | true 59 | -l"$(TargetName)" 60 | $(BDS)\bin\delphi_PROJECTICON.ico 61 | $(BDS)\bin\delphi_PROJECTICNS.icns 62 | RADServerD 63 | ..\..\..\out\lib\bpl 64 | ..\..\..\out\lib\$(Platform)\$(Config);$(DCC_UnitSearchPath) 65 | 66 | 67 | /usr/lib/ems/EMSDevServerCommand 68 | 69 | 70 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 71 | Debug 72 | true 73 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 74 | 1033 75 | $(BDS)\bin\EMSDevServer.exe 76 | 77 | 78 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) 79 | Debug 80 | true 81 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 82 | 1033 83 | $(BDS)\bin64\EMSDevServer.exe 84 | 85 | 86 | DEBUG;$(DCC_Define) 87 | true 88 | false 89 | true 90 | true 91 | true 92 | 93 | 94 | false 95 | true 96 | 1033 97 | 98 | 99 | false 100 | RELEASE;$(DCC_Define) 101 | 0 102 | 0 103 | 104 | 105 | 106 | MainSource 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 |
EmployeesResource1
120 | dfm 121 | TDataModule 122 |
123 | 124 | Cfg_2 125 | Base 126 | 127 | 128 | Base 129 | 130 | 131 | Cfg_1 132 | Base 133 | 134 |
135 | 136 | Delphi.Personality.12 137 | Package 138 | 139 | 140 | 141 | RADServerD.dpk 142 | 143 | 144 | Microsoft Office 2000 Sample Automation Server Wrapper Components 145 | Microsoft Office XP Sample Automation Server Wrapper Components 146 | Embarcadero C++Builder Office 2000 Servers Package 147 | Embarcadero C++Builder Office XP Servers Package 148 | 149 | 150 | 151 | 152 | 153 | true 154 | 155 | 156 | 157 | 158 | true 159 | 160 | 161 | 162 | 163 | true 164 | 165 | 166 | 167 | 168 | true 169 | 170 | 171 | 172 | 173 | RADServerD.bpl 174 | true 175 | 176 | 177 | 178 | 179 | 1 180 | 181 | 182 | Contents\MacOS 183 | 0 184 | 185 | 186 | 187 | 188 | classes 189 | 1 190 | 191 | 192 | 193 | 194 | library\lib\armeabi-v7a 195 | 1 196 | 197 | 198 | 199 | 200 | library\lib\armeabi 201 | 1 202 | 203 | 204 | 205 | 206 | library\lib\mips 207 | 1 208 | 209 | 210 | 211 | 212 | library\lib\armeabi-v7a 213 | 1 214 | 215 | 216 | 217 | 218 | res\drawable 219 | 1 220 | 221 | 222 | 223 | 224 | res\values 225 | 1 226 | 227 | 228 | 229 | 230 | res\drawable 231 | 1 232 | 233 | 234 | 235 | 236 | res\drawable-xxhdpi 237 | 1 238 | 239 | 240 | 241 | 242 | res\drawable-ldpi 243 | 1 244 | 245 | 246 | 247 | 248 | res\drawable-mdpi 249 | 1 250 | 251 | 252 | 253 | 254 | res\drawable-hdpi 255 | 1 256 | 257 | 258 | 259 | 260 | res\drawable-xhdpi 261 | 1 262 | 263 | 264 | 265 | 266 | res\drawable-small 267 | 1 268 | 269 | 270 | 271 | 272 | res\drawable-normal 273 | 1 274 | 275 | 276 | 277 | 278 | res\drawable-large 279 | 1 280 | 281 | 282 | 283 | 284 | res\drawable-xlarge 285 | 1 286 | 287 | 288 | 289 | 290 | 1 291 | 292 | 293 | 1 294 | 295 | 296 | 0 297 | 298 | 299 | 300 | 301 | 1 302 | .framework 303 | 304 | 305 | 0 306 | 307 | 308 | 309 | 310 | 1 311 | .dylib 312 | 313 | 314 | 0 315 | .dll;.bpl 316 | 317 | 318 | 319 | 320 | 1 321 | .dylib 322 | 323 | 324 | 1 325 | .dylib 326 | 327 | 328 | 1 329 | .dylib 330 | 331 | 332 | 1 333 | .dylib 334 | 335 | 336 | 0 337 | .bpl 338 | 339 | 340 | 341 | 342 | 0 343 | 344 | 345 | 0 346 | 347 | 348 | 0 349 | 350 | 351 | 0 352 | 353 | 354 | 0 355 | 356 | 357 | 0 358 | 359 | 360 | 361 | 362 | 1 363 | 364 | 365 | 1 366 | 367 | 368 | 1 369 | 370 | 371 | 372 | 373 | 1 374 | 375 | 376 | 1 377 | 378 | 379 | 1 380 | 381 | 382 | 383 | 384 | 1 385 | 386 | 387 | 1 388 | 389 | 390 | 1 391 | 392 | 393 | 394 | 395 | 1 396 | 397 | 398 | 1 399 | 400 | 401 | 1 402 | 403 | 404 | 405 | 406 | 1 407 | 408 | 409 | 1 410 | 411 | 412 | 1 413 | 414 | 415 | 416 | 417 | 1 418 | 419 | 420 | 1 421 | 422 | 423 | 1 424 | 425 | 426 | 427 | 428 | 1 429 | 430 | 431 | 1 432 | 433 | 434 | 1 435 | 436 | 437 | 438 | 439 | 1 440 | 441 | 442 | 443 | 444 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 445 | 1 446 | 447 | 448 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 449 | 1 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 1 458 | 459 | 460 | 1 461 | 462 | 463 | 1 464 | 465 | 466 | 467 | 468 | 469 | 470 | Contents\Resources 471 | 1 472 | 473 | 474 | 475 | 476 | library\lib\armeabi-v7a 477 | 1 478 | 479 | 480 | 1 481 | 482 | 483 | 1 484 | 485 | 486 | 1 487 | 488 | 489 | 1 490 | 491 | 492 | 1 493 | 494 | 495 | 0 496 | 497 | 498 | 499 | 500 | 1 501 | 502 | 503 | 1 504 | 505 | 506 | 507 | 508 | Assets 509 | 1 510 | 511 | 512 | Assets 513 | 1 514 | 515 | 516 | 517 | 518 | Assets 519 | 1 520 | 521 | 522 | Assets 523 | 1 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | True 537 | True 538 | True 539 | 540 | False 541 | 542 | 12 543 | 544 | 545 | 546 | 547 |
548 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/delphi/server/moduleMain.dfm: -------------------------------------------------------------------------------- 1 | object EmployeesResource1: TEmployeesResource1 2 | OldCreateOrder = False 3 | Height = 179 4 | Width = 214 5 | object conn: TFDConnection 6 | Params.Strings = ( 7 | 'ConnectionDef=EMPLOYEE') 8 | LoginPrompt = False 9 | Left = 52 10 | Top = 17 11 | end 12 | object qry: TFDQuery 13 | Connection = conn 14 | SQL.Strings = ( 15 | 'SELECT * FROM EMPLOYEE') 16 | Left = 52 17 | Top = 65 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/delphi/server/moduleMain.pas: -------------------------------------------------------------------------------- 1 | unit moduleMain; 2 | 3 | // EMS Resource Module 4 | 5 | interface 6 | 7 | uses 8 | System.SysUtils, System.Classes, System.JSON, 9 | EMS.Services, EMS.ResourceAPI, EMS.ResourceTypes, Data.DBXInterBase, 10 | Data.FMTBcd, Data.DB, Data.SqlExpr, FireDAC.Stan.Intf, FireDAC.Stan.Option, 11 | FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, 12 | FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.IB, 13 | FireDAC.Phys.IBDef, FireDAC.ConsoleUI.Wait, FireDAC.Stan.Param, FireDAC.DatS, 14 | FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet, FireDAC.Comp.Client; 15 | 16 | type 17 | [ResourceName('employees')] 18 | TEmployeesResource1 = class(TDataModule) 19 | conn: TFDConnection; 20 | qry: TFDQuery; 21 | published 22 | procedure Get(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); 23 | [ResourceSuffix('{item}')] 24 | procedure GetItem(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); 25 | procedure Post(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); 26 | [ResourceSuffix('{item}')] 27 | procedure PutItem(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); 28 | [ResourceSuffix('{item}')] 29 | procedure DeleteItem(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); 30 | end; 31 | 32 | implementation 33 | 34 | {%CLASSGROUP 'System.Classes.TPersistent'} 35 | 36 | {$R *.dfm} 37 | 38 | procedure TEmployeesResource1.Get(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); 39 | var 40 | a: TJSONArray; 41 | o: TJSONObject; 42 | begin 43 | qry.Active := true; 44 | if qry.Active then begin 45 | if qry.RecordCount>0 then begin 46 | a := TJSONArray.Create; 47 | try 48 | qry.First; 49 | while (not qry.Eof) do begin 50 | o := TJSONObject.Create; 51 | o.AddPair('EmployeeNumber',TJSONNumber.Create( qry.FieldByName('EMP_NO').AsInteger )); 52 | o.AddPair('FirstName',qry.FieldByName('FIRST_NAME').AsString ); 53 | o.AddPair('LastName',qry.FieldByName('LAST_NAME').AsString ); 54 | o.AddPair('PhoneExt',qry.FieldByName('PHONE_EXT').AsString ); 55 | o.AddPair('HireDate',qry.FieldByName('HIRE_DATE').AsString ); 56 | o.AddPair('DepartmentNumber',TJSONNumber.Create( qry.FieldByName('DEPT_NO').AsInteger )); 57 | o.AddPair('JobCode',qry.FieldByName('JOB_CODE').AsString ); 58 | o.AddPair('JobGrade',qry.FieldByName('JOB_GRADE').AsString ); 59 | o.AddPair('JobCountry', qry.FieldByName('JOB_COUNTRY').AsString ); 60 | o.AddPair('Salary', TJSONNumber.Create( qry.FieldByName('SALARY').AsFloat ) ); 61 | a.AddElement(o); 62 | qry.Next; 63 | end; 64 | finally 65 | AResponse.Body.SetValue(a,TRUE); 66 | end; 67 | end; 68 | end; 69 | end; 70 | 71 | procedure TEmployeesResource1.GetItem(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); 72 | var 73 | o: TJSONObject; 74 | EmployeeNumber: integer; 75 | begin 76 | EmployeeNumber := StrToInt(ARequest.Params.Values['item']); 77 | qry.SQL.Text := 'SELECT * FROM EMPLOYEE WHERE EMP_NO = :EMP_NO'; 78 | qry.Params.ParamByName('EMP_NO').AsInteger := EmployeeNumber; 79 | 80 | qry.Active := true; 81 | if qry.Active then begin 82 | if qry.RecordCount>0 then begin 83 | qry.First; 84 | o := TJSONObject.Create; 85 | o.AddPair('EmployeeNumber',TJSONNumber.Create( qry.FieldByName('EMP_NO').AsInteger )); 86 | o.AddPair('FirstName',qry.FieldByName('FIRST_NAME').AsString ); 87 | o.AddPair('LastName',qry.FieldByName('LAST_NAME').AsString ); 88 | o.AddPair('PhoneExt',qry.FieldByName('PHONE_EXT').AsString ); 89 | o.AddPair('HireDate',qry.FieldByName('HIRE_DATE').AsString ); 90 | o.AddPair('DepartmentNumber',TJSONNumber.Create( qry.FieldByName('DEPT_NO').AsInteger )); 91 | o.AddPair('JobCode',qry.FieldByName('JOB_CODE').AsString ); 92 | o.AddPair('JobGrade',qry.FieldByName('JOB_GRADE').AsString ); 93 | o.AddPair('JobCountry', qry.FieldByName('JOB_COUNTRY').AsString ); 94 | o.AddPair('Salary', TJSONNumber.Create( qry.FieldByName('SALARY').AsFloat ) ); 95 | AResponse.Body.SetValue(o,TRUE); 96 | end; 97 | end; 98 | end; 99 | 100 | 101 | procedure TEmployeesResource1.Post(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); 102 | var 103 | RequestObject: TJSONObject; 104 | NewRecordID: int32; 105 | o: TJSONObject; 106 | begin 107 | // Parse the JSON 108 | RequestObject := ARequest.Body.GetObject; 109 | 110 | // Insert New Record 111 | qry.SQL.Text := 'insert into employee ( '+ 112 | ' FIRST_NAME, '+ 113 | ' LAST_NAME, '+ 114 | ' PHONE_EXT, '+ 115 | ' HIRE_DATE, '+ 116 | ' DEPT_NO, '+ 117 | ' JOB_CODE, '+ 118 | ' JOB_GRADE, '+ 119 | ' JOB_COUNTRY, '+ 120 | ' SALARY ) values( ' + 121 | ' :FIRST_NAME, '+ 122 | ' :LAST_NAME, '+ 123 | ' :PHONE_EXT, '+ 124 | ' :HIRE_DATE, '+ 125 | ' :DEPT_NO, '+ 126 | ' :JOB_CODE, '+ 127 | ' :JOB_GRADE, '+ 128 | ' :JOB_COUNTRY, '+ 129 | ' :SALARY);'; 130 | 131 | // Set query parameters. 132 | qry.Params.ParamByName('FIRST_NAME').AsString := RequestObject.GetValue('FirstName').Value; 133 | qry.Params.ParamByName('LAST_NAME').AsString := RequestObject.GetValue('LastName').Value; 134 | qry.Params.ParamByName('PHONE_EXT').AsString := RequestObject.GetValue('PhoneExt').Value; 135 | qry.Params.ParamByName('HIRE_DATE').AsDateTime := StrToDateTime(RequestObject.GetValue('HireDate').Value); 136 | qry.Params.ParamByName('DEPT_NO').AsInteger := StrToInt(RequestObject.GetValue('DepartmentNumber').Value); 137 | qry.Params.ParamByName('JOB_CODE').AsString := RequestObject.GetValue('JobCode').Value; 138 | qry.Params.ParamByName('JOB_GRADE').AsInteger := StrToInt(RequestObject.GetValue('JobGrade').Value); 139 | qry.Params.ParamByName('JOB_COUNTRY').AsString := RequestObject.GetValue('JobCountry').Value; 140 | qry.Params.ParamByName('SALARY').AsFloat := StrToFloat(RequestObject.GetValue('Salary').Value); 141 | 142 | // Execute SQL 143 | qry.ExecSQL; 144 | 145 | // Get new record ID from Generator. 146 | qry.SQL.Text := 'select GEN_ID(EMP_NO_GEN,0) as ID from RDB$DATABASE;'; 147 | qry.Active := True; 148 | qry.First; 149 | NewRecordID := qry.Fields.FieldByName('ID').AsInteger; 150 | qry.Active := False; 151 | 152 | // Build the JSON response. 153 | o := TJSONObject.Create; 154 | o.AddPair('EmployeeNumber',TJSONNumber.Create(NewRecordID)); 155 | AResponse.Body.SetValue(o,TRUE); 156 | end; 157 | 158 | procedure TEmployeesResource1.PutItem(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); 159 | var 160 | EmployeeNumber: integer; 161 | RequestObject: TJSONObject; 162 | o: TJSONObject; 163 | begin 164 | EmployeeNumber := StrToInt(ARequest.Params.Values['item']); 165 | 166 | // Parse the JSON 167 | RequestObject := ARequest.Body.GetObject; 168 | 169 | // Insert New Record 170 | qry.SQL.Text := 'update employee SET '+ 171 | ' FIRST_NAME = :FIRST_NAME, '+ 172 | ' LAST_NAME = :LAST_NAME, '+ 173 | ' PHONE_EXT = :PHONE_EXT, '+ 174 | ' HIRE_DATE = :HIRE_DATE, '+ 175 | ' DEPT_NO = :DEPT_NO, '+ 176 | ' JOB_CODE = :JOB_CODE, '+ 177 | ' JOB_GRADE = :JOB_GRADE, '+ 178 | ' JOB_COUNTRY = :JOB_COUNTRY, '+ 179 | ' SALARY = :SALARY ' + 180 | ' WHERE EMP_NO = :EMP_NO; '; 181 | 182 | // Set query parameters. 183 | qry.Params.ParamByName('EMP_NO').AsInteger := EmployeeNumber; 184 | qry.Params.ParamByName('FIRST_NAME').AsString := RequestObject.GetValue('FirstName').Value; 185 | qry.Params.ParamByName('LAST_NAME').AsString := RequestObject.GetValue('LastName').Value; 186 | qry.Params.ParamByName('PHONE_EXT').AsString := RequestObject.GetValue('PhoneExt').Value; 187 | qry.Params.ParamByName('HIRE_DATE').AsDateTime := StrToDateTime(RequestObject.GetValue('HireDate').Value); 188 | qry.Params.ParamByName('DEPT_NO').AsInteger := StrToInt(RequestObject.GetValue('DepartmentNumber').Value); 189 | qry.Params.ParamByName('JOB_CODE').AsString := RequestObject.GetValue('JobCode').Value; 190 | qry.Params.ParamByName('JOB_GRADE').AsInteger := StrToInt(RequestObject.GetValue('JobGrade').Value); 191 | qry.Params.ParamByName('JOB_COUNTRY').AsString := RequestObject.GetValue('JobCountry').Value; 192 | qry.Params.ParamByName('SALARY').AsFloat := StrToFloat(RequestObject.GetValue('Salary').Value); 193 | 194 | // Execute SQL 195 | qry.ExecSQL; 196 | 197 | // Build the JSON response. 198 | o := TJSONObject.Create; 199 | o.AddPair('EmployeeNumber',TJSONNumber.Create(EmployeeNumber)); 200 | AResponse.Body.SetValue(o,TRUE); 201 | end; 202 | 203 | procedure TEmployeesResource1.DeleteItem(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); 204 | var 205 | o: TJSONObject; 206 | EmployeeNumber: integer; 207 | begin 208 | // Get employee number parameter 209 | EmployeeNumber := StrToInt(ARequest.Params.Values['item']); 210 | 211 | // Insert New Record 212 | qry.SQL.Text := 'DELETE FROM employee WHERE EMP_NO = :EMP_NO; '; 213 | 214 | // Set query parameters. 215 | qry.Params.ParamByName('EMP_NO').AsInteger := EmployeeNumber; 216 | 217 | // Execute SQL 218 | qry.ExecSQL; 219 | 220 | // Build the JSON response. 221 | o := TJSONObject.Create; 222 | o.AddPair('EmployeeNumber',TJSONNumber.Create(EmployeeNumber)); 223 | AResponse.Body.SetValue(o,TRUE); 224 | end; 225 | 226 | procedure Register; 227 | begin 228 | RegisterResource(TypeInfo(TEmployeesResource1)); 229 | end; 230 | 231 | initialization 232 | Register; 233 | end. 234 | 235 | 236 | -------------------------------------------------------------------------------- /Craig Chapman/RADServerSample/src/grpRADServerSample.groupproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {0EAF7684-49DD-436B-9B31-964DBFB78946} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Default.Personality.12 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/CppSuperCalculator.cbproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {8030CDE0-EFE5-471B-9DEF-53F311489617} 4 | 18.2 5 | FMX 6 | CppSuperCalculator.cpp 7 | True 8 | Debug 9 | Win64 10 | 3 11 | Application 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Base 29 | true 30 | 31 | 32 | true 33 | Base 34 | true 35 | 36 | 37 | true 38 | Cfg_1 39 | true 40 | true 41 | 42 | 43 | true 44 | Cfg_1 45 | true 46 | true 47 | 48 | 49 | true 50 | Cfg_1 51 | true 52 | true 53 | 54 | 55 | true 56 | Base 57 | true 58 | 59 | 60 | true 61 | Cfg_2 62 | true 63 | true 64 | 65 | 66 | true 67 | Cfg_2 68 | true 69 | true 70 | 71 | 72 | true 73 | CppSuperCalculator 74 | true 75 | <_TCHARMapping>wchar_t 76 | $(BDS)\bin\cbuilder_PROJECTICNS.icns 77 | starter-calculator\;$(ILINK_LibraryPath) 78 | FmxGuiApplication 79 | true 80 | true 81 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 82 | rtl.lib;fmx.lib 83 | true 84 | $(BDS)\bin\cbuilder_PROJECTICON.ico 85 | true 86 | starter-calculator\;$(IncludePath) 87 | true 88 | true 89 | true 90 | true 91 | true 92 | JPHNE 93 | true 94 | true 95 | .\$(Platform)\$(Config) 96 | .\$(Platform)\$(Config) 97 | false 98 | true 99 | true 100 | $(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath) 101 | 102 | 103 | $(BDS)\bin\Artwork\Android\FM_SplashImage_470x320.png 104 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_96x96.png 105 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_36x36.png 106 | Debug 107 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_48x48.png 108 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_144x144.png 109 | true 110 | $(BDS)\bin\Artwork\Android\FM_SplashImage_960x720.png 111 | $(BDS)\bin\Artwork\Android\FM_LauncherIcon_72x72.png 112 | false 113 | $(BDSINCLUDE)\android\fmx;$(IncludePath) 114 | bindcomp;bindcompdbx;bindcompfmx;bindengine;CloudService;CustomIPTransport;DataSnapClient;DataSnapCommon;DataSnapFireDAC;DataSnapNativeClient;DataSnapProviderClient;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXInterBaseDriver;DBXSqliteDriver;dsnap;dsnapxml;emsclient;emsclientfiredac;FireDAC;FireDACCommon;FireDACCommonDriver;FireDACDBXDriver;FireDACDSDriver;FireDACIBDriver;FireDACSqliteDriver;fmx;fmxFireDAC;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;RESTBackendComponents;RESTComponents;rtl;soapmidas;soaprtl;soapserver;tethering;xmlrtl;$(PackageImports) 115 | package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey= 116 | $(BDS)\bin\Artwork\Android\FM_SplashImage_426x320.png 117 | $(BDS)\bin\Artwork\Android\FM_SplashImage_640x480.png 118 | android-support-v4.dex.jar;cloud-messaging.dex.jar;fmx.dex.jar;google-analytics-v2.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar;google-play-services.dex.jar 119 | 120 | 121 | 1033 122 | Debug 123 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 124 | $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png 125 | true 126 | adortl;appanalytics;bcbie;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindengine;CloudService;CustomIPTransport;DataSnapClient;DataSnapCommon;DataSnapConnectors;DatasnapConnectorsFreePascal;DataSnapFireDAC;DataSnapIndy10ServerTransport;DataSnapNativeClient;DataSnapProviderClient;DataSnapServer;DataSnapServerMidas;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXDb2Driver;DBXFirebirdDriver;DBXInformixDriver;DBXInterBaseDriver;DBXMSSQLDriver;DBXMySQLDriver;DBXOdbcDriver;DBXOracleDriver;DBXSqliteDriver;DBXSybaseASADriver;DBXSybaseASEDriver;dsnap;dsnapcon;dsnapxml;emsclient;emsclientfiredac;emsedge;emshosting;FireDAC;FireDACADSDriver;FireDACASADriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACDb2Driver;FireDACDBXDriver;FireDACDSDriver;FireDACIBDriver;FireDACInfxDriver;FireDACMongoDBDriver;FireDACMSAccDriver;FireDACMSSQLDriver;FireDACMySQLDriver;FireDACODBCDriver;FireDACOracleDriver;FireDACPgDriver;FireDACSqliteDriver;FireDACTDataDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;RESTBackendComponents;RESTComponents;rtl;soapmidas;soaprtl;soapserver;svn;tethering;vcl;vclactnband;vcldb;vcldsnap;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports) 127 | $(BDSINCLUDE)\windows\fmx;$(IncludePath) 128 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 129 | $(BDS)\bin\default_app.manifest 130 | $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png 131 | 132 | 133 | 1033 134 | Debug 135 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) 136 | $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png 137 | true 138 | adortl;appanalytics;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindengine;CloudService;CustomIPTransport;DataSnapClient;DataSnapCommon;DataSnapConnectors;DatasnapConnectorsFreePascal;DataSnapFireDAC;DataSnapIndy10ServerTransport;DataSnapNativeClient;DataSnapProviderClient;DataSnapServer;DataSnapServerMidas;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXDb2Driver;DBXFirebirdDriver;DBXInformixDriver;DBXInterBaseDriver;DBXMSSQLDriver;DBXMySQLDriver;DBXOdbcDriver;DBXOracleDriver;DBXSqliteDriver;DBXSybaseASADriver;DBXSybaseASEDriver;dsnap;dsnapcon;dsnapxml;emsclient;emsclientfiredac;emsedge;emshosting;FireDAC;FireDACADSDriver;FireDACASADriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACDb2Driver;FireDACDBXDriver;FireDACDSDriver;FireDACIBDriver;FireDACInfxDriver;FireDACMongoDBDriver;FireDACMSAccDriver;FireDACMSSQLDriver;FireDACMySQLDriver;FireDACODBCDriver;FireDACOracleDriver;FireDACPgDriver;FireDACSqliteDriver;FireDACTDataDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;RESTBackendComponents;RESTComponents;rtl;soapmidas;soaprtl;soapserver;tethering;vcl;vclactnband;vcldb;vcldsnap;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports) 139 | $(BDSINCLUDE)\windows\fmx;$(IncludePath) 140 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 141 | $(BDS)\bin\default_app.manifest 142 | $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png 143 | 144 | 145 | false 146 | true 147 | false 148 | true 149 | _DEBUG;$(Defines) 150 | false 151 | None 152 | DEBUG 153 | true 154 | true 155 | true 156 | true 157 | Full 158 | true 159 | true 160 | true 161 | true 162 | true 163 | $(BDSLIB)\$(PLATFORM)\debug;$(ILINK_LibraryPath) 164 | $(BDSLIB)\$(PLATFORM)\debug\$(LANGDIR);$(ILINK_TranslatedLibraryPath) 165 | 166 | 167 | rtl.lib;fmx.lib 168 | 169 | 170 | true 171 | true 172 | true 173 | rtl.bpi;fmx.bpi 174 | false 175 | 1033 176 | 177 | 178 | rtl.bpi;fmx.bpi 179 | true 180 | true 181 | 182 | 183 | NDEBUG;$(Defines) 184 | None 185 | 186 | 187 | true 188 | true 189 | 190 | 191 | true 192 | true 193 | 194 | 195 | 196 | 0 197 | 198 | 199 | 2 200 | true 201 | 202 | 203 | uCalculator.h 204 | 6 205 | 206 | 207 |
frmCalculator
208 | fmx 209 | uFormCalculator.h 210 | 5 211 |
212 | 213 | uInterfaces.h 214 | 4 215 | 216 | 217 | uOperator.h 218 | 3 219 | 220 | 221 | 222 | Cfg_2 223 | Base 224 | 225 | 226 | Base 227 | 228 | 229 | Cfg_1 230 | Base 231 | 232 |
233 | 234 | CPlusPlusBuilder.Personality.12 235 | FmxGuiApplication 236 | 237 | 238 | 239 | False 240 | True 241 | True 242 | False 243 | 244 | 245 | CppSuperCalculator.cpp 246 | 247 | 248 | Embarcadero C++Builder Office 2000 Servers Package 249 | Embarcadero C++Builder Office XP Servers Package 250 | Microsoft Office 2000 Sample Automation Server Wrapper Components 251 | Microsoft Office XP Sample Automation Server Wrapper Components 252 | 253 | 254 | 255 | 256 | 257 | true 258 | 259 | 260 | 261 | 262 | true 263 | 264 | 265 | 266 | 267 | true 268 | 269 | 270 | 271 | 272 | true 273 | 274 | 275 | 276 | 277 | true 278 | 279 | 280 | 281 | 282 | CppSuperCalculator.tds 283 | true 284 | 285 | 286 | 287 | 288 | true 289 | 290 | 291 | 292 | 293 | true 294 | 295 | 296 | 297 | 298 | true 299 | 300 | 301 | 302 | 303 | true 304 | 305 | 306 | 307 | 308 | true 309 | 310 | 311 | 312 | 313 | true 314 | 315 | 316 | 317 | 318 | true 319 | 320 | 321 | 322 | 323 | true 324 | 325 | 326 | 327 | 328 | CppSuperCalculator.exe 329 | true 330 | 331 | 332 | 333 | 334 | true 335 | 336 | 337 | 338 | 339 | 0 340 | .dll;.bpl 341 | 342 | 343 | 1 344 | .dylib 345 | 346 | 347 | Contents\MacOS 348 | 1 349 | .dylib 350 | 351 | 352 | 1 353 | .dylib 354 | 355 | 356 | 1 357 | .dylib 358 | 359 | 360 | 361 | 362 | Contents\Resources 363 | 1 364 | 365 | 366 | 367 | 368 | classes 369 | 1 370 | 371 | 372 | 373 | 374 | Contents\MacOS 375 | 0 376 | 377 | 378 | 1 379 | 380 | 381 | Contents\MacOS 382 | 1 383 | 384 | 385 | 386 | 387 | 1 388 | 389 | 390 | 1 391 | 392 | 393 | 1 394 | 395 | 396 | 397 | 398 | res\drawable-xxhdpi 399 | 1 400 | 401 | 402 | 403 | 404 | library\lib\mips 405 | 1 406 | 407 | 408 | 409 | 410 | 1 411 | 412 | 413 | 1 414 | 415 | 416 | 0 417 | 418 | 419 | 1 420 | 421 | 422 | Contents\MacOS 423 | 1 424 | 425 | 426 | library\lib\armeabi-v7a 427 | 1 428 | 429 | 430 | 1 431 | 432 | 433 | 434 | 435 | 0 436 | 437 | 438 | Contents\MacOS 439 | 1 440 | .framework 441 | 442 | 443 | 444 | 445 | 1 446 | 447 | 448 | 1 449 | 450 | 451 | 452 | 453 | 1 454 | 455 | 456 | 1 457 | 458 | 459 | 1 460 | 461 | 462 | 463 | 464 | 1 465 | 466 | 467 | 1 468 | 469 | 470 | 1 471 | 472 | 473 | 474 | 475 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 476 | 1 477 | 478 | 479 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 480 | 1 481 | 482 | 483 | 484 | 485 | 1 486 | 487 | 488 | 1 489 | 490 | 491 | 1 492 | 493 | 494 | 495 | 496 | 1 497 | 498 | 499 | 1 500 | 501 | 502 | 1 503 | 504 | 505 | 506 | 507 | library\lib\armeabi 508 | 1 509 | 510 | 511 | 512 | 513 | 0 514 | 515 | 516 | 1 517 | 518 | 519 | Contents\MacOS 520 | 1 521 | 522 | 523 | 524 | 525 | 1 526 | 527 | 528 | 1 529 | 530 | 531 | 1 532 | 533 | 534 | 535 | 536 | res\drawable-normal 537 | 1 538 | 539 | 540 | 541 | 542 | res\drawable-xhdpi 543 | 1 544 | 545 | 546 | 547 | 548 | res\drawable-large 549 | 1 550 | 551 | 552 | 553 | 554 | 1 555 | 556 | 557 | 1 558 | 559 | 560 | 1 561 | 562 | 563 | 564 | 565 | ..\ 566 | 1 567 | 568 | 569 | ..\ 570 | 1 571 | 572 | 573 | 574 | 575 | res\drawable-hdpi 576 | 1 577 | 578 | 579 | 580 | 581 | library\lib\armeabi-v7a 582 | 1 583 | 584 | 585 | 586 | 587 | Contents 588 | 1 589 | 590 | 591 | 592 | 593 | ..\ 594 | 1 595 | 596 | 597 | 598 | 599 | Assets 600 | 1 601 | 602 | 603 | Assets 604 | 1 605 | 606 | 607 | 608 | 609 | 1 610 | 611 | 612 | 1 613 | 614 | 615 | 1 616 | 617 | 618 | 619 | 620 | res\values 621 | 1 622 | 623 | 624 | 625 | 626 | res\drawable-small 627 | 1 628 | 629 | 630 | 631 | 632 | res\drawable 633 | 1 634 | 635 | 636 | 637 | 638 | 1 639 | 640 | 641 | 1 642 | 643 | 644 | 1 645 | 646 | 647 | 648 | 649 | 1 650 | 651 | 652 | 653 | 654 | res\drawable 655 | 1 656 | 657 | 658 | 659 | 660 | Assets 661 | 1 662 | 663 | 664 | Assets 665 | 1 666 | 667 | 668 | 669 | 670 | 0 671 | 672 | 673 | 0 674 | 675 | 676 | Contents\Resources\StartUp\ 677 | 0 678 | 679 | 680 | 0 681 | 682 | 683 | 0 684 | 685 | 686 | 0 687 | 688 | 689 | 690 | 691 | library\lib\armeabi-v7a 692 | 1 693 | 694 | 695 | 696 | 697 | 0 698 | .bpl 699 | 700 | 701 | 1 702 | .dylib 703 | 704 | 705 | Contents\MacOS 706 | 1 707 | .dylib 708 | 709 | 710 | 1 711 | .dylib 712 | 713 | 714 | 1 715 | .dylib 716 | 717 | 718 | 719 | 720 | res\drawable-mdpi 721 | 1 722 | 723 | 724 | 725 | 726 | res\drawable-xlarge 727 | 1 728 | 729 | 730 | 731 | 732 | res\drawable-ldpi 733 | 1 734 | 735 | 736 | 737 | 738 | 1 739 | 740 | 741 | 1 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | False 755 | True 756 | True 757 | 758 | 759 | 12 760 | 761 | 762 | 763 | 764 |
765 | -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/CppSuperCalculator.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #ifdef _WIN32 5 | #include 6 | #endif 7 | #pragma hdrstop 8 | #include 9 | //--------------------------------------------------------------------------- 10 | USEFORM("uFormCalculator.cpp", frmCalculator); 11 | //--------------------------------------------------------------------------- 12 | extern "C" int FMXmain() 13 | { 14 | try 15 | { 16 | Application->Initialize(); 17 | Application->CreateForm(__classid(TfrmCalculator), &frmCalculator); 18 | Application->Run(); 19 | } 20 | catch (Exception &exception) 21 | { 22 | Application->ShowException(&exception); 23 | } 24 | catch (...) 25 | { 26 | try 27 | { 28 | throw Exception(""); 29 | } 30 | catch (Exception &exception) 31 | { 32 | Application->ShowException(&exception); 33 | } 34 | } 35 | return 0; 36 | } 37 | //--------------------------------------------------------------------------- 38 | -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/CppSuperCalculatorPCH1.h: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef _WIN32 3 | #include 4 | #endif 5 | 6 | -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/README.md: -------------------------------------------------------------------------------- 1 | # Learn to program with C++Builder: C++ Calculator 2 | 3 | Source code from the blog series on learning C++ with C++Builder. It's not 'learning to program' - this assumes you already have some basic programming knowledge, including object orientation, pointers, etc - but rather, 'learning to program with C++'. 4 | 5 | The series covers installing the free Starter edition of C++Builder; cross-platform UI design; good architectural principles such as UI / logic separation, ownership, etc; introduces basic C++ syntax; introduces a number of useful concepts and classes, such as unique pointers and optional; and puts all these together demonstrating their use in a simple math calculator program of the sort you might see on the iOS or Android app stores. 6 | 7 | [Read each post in the series here](https://community.embarcadero.com/blogs?view=entry&id=9140). 8 | -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/uCalculator.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #pragma hdrstop 4 | 5 | #include "uCalculator.h" 6 | #include 7 | #include 8 | 9 | Accumulator::Accumulator() : 10 | m_Whole(), 11 | m_Frac(), 12 | m_FracLeadingZeros(0), 13 | m_EnteringFraction(false) 14 | { 15 | } 16 | 17 | bool Accumulator::Entering() const { 18 | // Is user entering a number? 19 | return (m_Whole || m_Frac || (m_FracLeadingZeros > 0)); // If none of these, nothing entered 20 | } 21 | 22 | double Accumulator::Value() const { 23 | return Whole() + Frac(); 24 | } 25 | 26 | std::wstring Accumulator::ValueStr() const { 27 | std::wstringstream str; 28 | 29 | str << Whole(); 30 | if (m_FracLeadingZeros > 0 || m_Frac) { 31 | str << L"."; 32 | str << std::wstring(m_FracLeadingZeros, L'0'); // Writes, eg, '000' for 3 33 | if (m_Frac) { 34 | str << *m_Frac; 35 | } 36 | } 37 | 38 | return str.str(); 39 | } 40 | 41 | double Accumulator::Whole() const { 42 | if (m_Whole) { 43 | return *m_Whole; 44 | } 45 | return 0.0; 46 | } 47 | 48 | double Accumulator::Frac() const { 49 | // Convert an integer like 123 to 0.123 50 | // Magnitude can be calculated via log10 51 | // log10(123) -> 2, +1 -> 3 52 | // pow(10, 3) -> 1000 53 | // 123 / 100 = 0.123 54 | // Note leading zeroes - handle separately 55 | if (m_Frac && (*m_Frac != 0)) { 56 | return *m_Frac / pow(10, floor(log10(*m_Frac) + m_FracLeadingZeros + 1)); 57 | } 58 | return 0.0; 59 | } 60 | 61 | void Accumulator::SetEnteringFraction() { 62 | m_EnteringFraction = true; 63 | } 64 | 65 | int Accumulator::InternalAddDigit(const boost::optional& Value, const int Digit) { 66 | // Add a digit to the number. If it doesn't exist, the number is the digit 67 | if (Value) { 68 | return *Value * 10 + Digit; 69 | } else { 70 | return Digit; 71 | } 72 | } 73 | 74 | void Accumulator::AddDigit(const int Digit) { 75 | if (m_EnteringFraction) { 76 | // Leading zeroes won't get added, mathematically (to enter 1.00001, for 77 | // example, InternalAddDigit will multiply by 10 and add 0.) Track separately 78 | if (Digit == 0 && !m_Frac) { 79 | ++m_FracLeadingZeros; 80 | } else { 81 | m_Frac = InternalAddDigit(m_Frac, Digit); 82 | } 83 | } else { 84 | m_Whole = InternalAddDigit(m_Whole, Digit); 85 | } 86 | } 87 | 88 | //////////////////////////////////////////////////////////////////////////////// 89 | 90 | TCalculator::TCalculator(ICalculatorDisplay& Display) : 91 | m_Display(Display), 92 | m_Op(), 93 | m_Left(), 94 | m_Right(), 95 | m_Result(), 96 | m_Accum() 97 | { 98 | } 99 | 100 | TCalculator::~TCalculator() { 101 | } 102 | 103 | void TCalculator::AddDigit(const int Digit) { 104 | // Mimic typing into a calculator 105 | 106 | if (m_Result) { // typing after getting an answer. Clear 107 | m_Result.reset(); 108 | } 109 | m_Accum.AddDigit(Digit); 110 | UpdateUI(); 111 | } 112 | 113 | void TCalculator::AddDecimalSeparator() { 114 | m_Accum.SetEnteringFraction(); 115 | } 116 | 117 | void TCalculator::PromoteAccumulator() { 118 | // The accumulator has had the user enter digits 119 | // Now it needs to become a number 120 | // If don't have a left side, it's that 121 | // If do, and don't have a right side, it's that 122 | // If have both, then there is a logic error. 123 | 124 | if (!m_Accum.Entering()) { 125 | return; 126 | } 127 | 128 | if (!m_Left) { 129 | m_Left = m_Accum.Value(); 130 | } else { 131 | assert(!m_Right); 132 | m_Right = m_Accum.Value(); 133 | } 134 | // Reset 135 | m_Accum = Accumulator(); 136 | } 137 | 138 | void TCalculator::SetOperator(const EOperator Op) { 139 | if (Op == EOperator::eNull) { 140 | m_Op.reset(); 141 | } else { 142 | PromoteAccumulator(); // once the op changes, stop entering, make it a number 143 | 144 | // 1 + 2 [now press -] -> want to calc that, make it the left operand 145 | if (!m_Result && m_Left && m_Right) { 146 | Equals(); 147 | } 148 | if (m_Result) { 149 | // Operator after result -> want the result to be the new left operand 150 | m_Left = m_Result; 151 | m_Right.reset(); 152 | m_Result.reset(); 153 | } 154 | if (m_Left) { 155 | // Require a left operand, because all ops have to operate on at least 156 | // one operand 157 | m_Op = CreateOp(Op); 158 | } 159 | } 160 | 161 | UpdateUI(); 162 | } 163 | 164 | void TCalculator::Equals() { 165 | PromoteAccumulator(); 166 | 167 | if (m_Left && m_Right && m_Op) { 168 | m_Result = m_Op->Calc(*m_Left, *m_Right); 169 | m_Left.reset(); // No operands any more 170 | m_Right.reset(); 171 | SetOperator(EOperator::eNull); // Nothing to do any more 172 | } 173 | UpdateUI(); 174 | } 175 | 176 | void TCalculator::UpdateUI() { 177 | // What should the UI draw? 178 | // What's being typed in, so the accumulator if it's being typed in 179 | // The whole expression: if there is a left side, and an operator, 180 | // it should print that plus then the accumulator 181 | // The result: all operands, operator, equals. 182 | 183 | std::wstringstream stream; 184 | if (m_Left) { 185 | stream << *m_Left; 186 | 187 | if (m_Op) { 188 | stream << L" " << m_Op->Name() << L" "; 189 | 190 | if (m_Right) { 191 | stream << *m_Right; 192 | } else if (m_Accum.Entering()) { 193 | stream << m_Accum.ValueStr(); 194 | } 195 | } 196 | } else if (m_Accum.Entering()) { 197 | stream << m_Accum.ValueStr(); 198 | } else if (m_Result) { 199 | stream << *m_Result; 200 | } 201 | 202 | m_Display.UpdateUI(stream.str()); 203 | } 204 | -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/uCalculator.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef uCalculatorH 4 | #define uCalculatorH 5 | 6 | #include "uInterfaces.h" 7 | #include 8 | #include "uOperator.h" 9 | #include 10 | #include 11 | 12 | class Accumulator { 13 | private: 14 | boost::optional m_Whole; 15 | boost::optional m_Frac; 16 | int m_FracLeadingZeros; 17 | bool m_EnteringFraction; 18 | 19 | double Whole() const; 20 | double Frac() const; 21 | static int InternalAddDigit(const boost::optional& Value, const int Digit); 22 | public: 23 | Accumulator(); 24 | bool Entering() const; 25 | double Value() const; 26 | std::wstring ValueStr() const; 27 | void SetEnteringFraction(); 28 | void AddDigit(const int Digit); 29 | }; 30 | 31 | class TCalculator : public ICalculator { 32 | private: 33 | ICalculatorDisplay& m_Display; 34 | std::unique_ptr m_Op; 35 | boost::optional m_Left; 36 | boost::optional m_Right; 37 | boost::optional m_Result; 38 | Accumulator m_Accum; 39 | 40 | void PromoteAccumulator(); 41 | void UpdateUI(); 42 | public: 43 | TCalculator(ICalculatorDisplay& Display); 44 | virtual ~TCalculator(); 45 | public: // ICalculator 46 | virtual void AddDigit(const int Digit); 47 | virtual void AddDecimalSeparator(); 48 | virtual void SetOperator(const EOperator Op); 49 | virtual void Equals(); 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/uFormCalculator.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | 6 | #include "uFormCalculator.h" 7 | #include "uInterfaces.h" 8 | 9 | #pragma package(smart_init) 10 | #pragma resource "*.fmx" 11 | TfrmCalculator *frmCalculator; 12 | 13 | //--------------------------------------------------------------------------- 14 | __fastcall TfrmCalculator::TfrmCalculator(TComponent* Owner) : 15 | TForm(Owner), 16 | m_Calc(CreateCalculator(*this)) 17 | { 18 | } 19 | 20 | //--------------------------------------------------------------------------- 21 | void TfrmCalculator::UpdateUI(const std::wstring& strText) { 22 | edtResult->Text = strText.c_str(); 23 | } 24 | 25 | //--------------------------------------------------------------------------- 26 | void __fastcall TfrmCalculator::btnAddClick(TObject *Sender) 27 | { 28 | m_Calc->SetOperator(EOperator::eAdd); 29 | } 30 | 31 | //--------------------------------------------------------------------------- 32 | 33 | void __fastcall TfrmCalculator::btnSubtractClick(TObject *Sender) 34 | { 35 | m_Calc->SetOperator(EOperator::eSubtract); 36 | } 37 | //--------------------------------------------------------------------------- 38 | 39 | void __fastcall TfrmCalculator::btnMultiplyClick(TObject *Sender) 40 | { 41 | m_Calc->SetOperator(EOperator::eMultiply); 42 | } 43 | 44 | //--------------------------------------------------------------------------- 45 | void __fastcall TfrmCalculator::btnDivideClick(TObject *Sender) 46 | { 47 | m_Calc->SetOperator(EOperator::eDivide); 48 | } 49 | 50 | //--------------------------------------------------------------------------- 51 | 52 | void __fastcall TfrmCalculator::btnEqualsClick(TObject *Sender) 53 | { 54 | m_Calc->Equals(); 55 | } 56 | //--------------------------------------------------------------------------- 57 | 58 | void __fastcall TfrmCalculator::btnDecimalPointClick(TObject *Sender) 59 | { 60 | m_Calc->AddDecimalSeparator(); 61 | } 62 | //--------------------------------------------------------------------------- 63 | 64 | void __fastcall TfrmCalculator::btnNumberClick(TObject *Sender) 65 | { 66 | m_Calc->AddDigit(dynamic_cast(Sender)->Tag); 67 | } 68 | //--------------------------------------------------------------------------- 69 | 70 | 71 | -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/uFormCalculator.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef uFormCalculatorH 4 | #define uFormCalculatorH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "uInterfaces.h" 14 | #include 15 | //--------------------------------------------------------------------------- 16 | class TfrmCalculator : public TForm, ICalculatorDisplay 17 | { 18 | __published: // IDE-managed Components 19 | TButton *btnZero; 20 | TButton *btnDecimalPoint; 21 | TButton *btnDivide; 22 | TButton *btnMultiply; 23 | TButton *btnSubtract; 24 | TButton *btnAdd; 25 | TButton *btnEquals; 26 | TButton *btnTwo; 27 | TButton *btnNine; 28 | TButton *btnEight; 29 | TButton *btnSeven; 30 | TButton *btnSix; 31 | TButton *btnFive; 32 | TButton *btnFour; 33 | TButton *btnThree; 34 | TButton *btnOne; 35 | TEdit *edtResult; 36 | TStyleBook *StyleBook1; 37 | void __fastcall btnAddClick(TObject *Sender); 38 | void __fastcall btnSubtractClick(TObject *Sender); 39 | void __fastcall btnMultiplyClick(TObject *Sender); 40 | void __fastcall btnDivideClick(TObject *Sender); 41 | void __fastcall btnEqualsClick(TObject *Sender); 42 | void __fastcall btnDecimalPointClick(TObject *Sender); 43 | void __fastcall btnNumberClick(TObject *Sender); 44 | private: // User declarations 45 | std::unique_ptr m_Calc; 46 | public: // User declarations 47 | __fastcall TfrmCalculator(TComponent* Owner); 48 | virtual void UpdateUI(const std::wstring& strText); 49 | }; 50 | //--------------------------------------------------------------------------- 51 | extern PACKAGE TfrmCalculator *frmCalculator; 52 | //--------------------------------------------------------------------------- 53 | #endif 54 | -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/uInterfaces.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #pragma hdrstop 4 | #include "uInterfaces.h" 5 | #include "uCalculator.h" 6 | 7 | std::unique_ptr CreateCalculator(ICalculatorDisplay& Display) { 8 | return make_unique(Display); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/uInterfaces.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef uInterfacesH 4 | #define uInterfacesH 5 | 6 | #include 7 | #include 8 | 9 | // From http://stackoverflow.com/questions/7038357/make-unique-and-perfect-forwarding 10 | template 11 | std::unique_ptr make_unique(Args&&... args) 12 | { 13 | return std::unique_ptr(new T(std::forward(args)...)); 14 | } 15 | 16 | class ICalculatorDisplay { 17 | public: 18 | //virtual __fastcall ~ICalculatorDisplay() {}; 19 | virtual void UpdateUI(const std::wstring& strText) = 0; 20 | }; 21 | 22 | enum class EOperator { 23 | eNull, 24 | eAdd, 25 | eSubtract, 26 | eMultiply, 27 | eDivide 28 | }; 29 | 30 | class ICalculator { 31 | public: 32 | virtual ~ICalculator() {}; 33 | 34 | virtual void AddDigit(const int Digit) = 0; 35 | virtual void AddDecimalSeparator() = 0; 36 | virtual void SetOperator(const EOperator Op) = 0; 37 | virtual void Equals() = 0; 38 | }; 39 | 40 | std::unique_ptr CreateCalculator(ICalculatorDisplay& Display); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/uOperator.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Embarcadero/Blogs/c10d03d534cc115e0f9dfe6bedcd84d44b8c6f5d/David Millington/Learning C++ with C++Builder - Calculator/uOperator.cpp -------------------------------------------------------------------------------- /David Millington/Learning C++ with C++Builder - Calculator/uOperator.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef uOperatorH 4 | #define uOperatorH 5 | 6 | #include 7 | #include 8 | #include "uInterfaces.h" 9 | 10 | class IOperator { 11 | public: 12 | virtual double Calc(const double A,const double B) = 0; 13 | virtual std::wstring Name() const = 0; 14 | }; 15 | 16 | std::unique_ptr CreateOp(const EOperator Op); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /David Millington/README.md: -------------------------------------------------------------------------------- 1 | Source code from blog posts written by David Millington. Check the readme in each folder for more details. 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blogs 2 | Source code associated with Embarcadero blog posts 3 | --------------------------------------------------------------------------------