Norbert's Game Engine v200
Loading...
Searching...
No Matches
EDR Namespace Reference

Classes

struct  ZSTAT
 

Typedefs

typedef zip Archive
 

Functions

strg GetString (strg file, strg token, const bool binary=false)
 Return the tokens value as a std::string.
 
real6 GetNumber (strg file, strg token, const bool binary=false)
 Return the tokens value as a real6.
 
int GetInt (strg file, strg token, const bool binary=false)
 Return the tokens value as an int.
 
bool GetBool (strg file, strg token, const bool binary=false)
 Return the tokens value as a bool.
 
const uint SetValue (strg file, strg value, const bool binary=false)
 Set a tokens value.
 
const uint ChangeValue (strg file, strg token, strg value, const bool binary=false)
 Change a tokens value.
 
void CreateDirectoryExt (const char *dir)
 Creates a directory on drive.
 
void DeleteDirectory (const char *dir)
 Removes a directory from drive.
 
void WriteFile (const char *dir, strg content)
 Write a file to drive.
 
void WriteBinary (const char *dir, strg content)
 Write binary text to drive.
 
strg ReadBinary (const char *dir)
 Read binary text from drive.
 
void ConvertToBinary (strg &text)
 Convert text to binary string.
 
void ConvertToText (strg &binary)
 Convert binary string to text.
 
strg GetContext (strg filePath, const bool binary=false)
 Returns a files content.
 
void RemoveFile (const char *filePath)
 Removes a file from the drive.
 
bool FileExists (const char *path)
 
std::vector< strg > GetFilesInDir (strg dir, const int nt)
 
strg WriteBinaryToString (strg &content)
 Write binary text to memory.
 
strg ReadBinaryToString (strg &content)
 Read binary text from memory.
 
strg GetStringG (strg file, strg token, strg group, const bool binary=false)
 For reading in a group.
 
real6 GetNumberG (strg file, strg token, strg group, const bool binary=false)
 For reading in a group.
 
int GetIntG (strg file, strg token, strg group, const bool binary=false)
 For reading in a group.
 
bool GetBoolG (strg file, strg token, strg group, const bool binary=false)
 For reading in a group.
 
strg GetStringGI (strg file, strg token, strg group, const bool binary=false)
 From memory.
 
real6 GetNumberGI (strg file, strg token, strg group, const bool binary=false)
 From memory.
 
int GetIntGI (strg file, strg token, strg group, const bool binary=false)
 From memory.
 
bool GetBoolGI (strg file, strg token, strg group, const bool binary=false)
 From memory.
 
strg GetStringSG (strg file, strg token, strg group, strg groupS, const bool binary=false)
 For reading in a sub-group.
 
real6 GetNumberSG (strg file, strg token, strg group, strg groupS, const bool binary=false)
 For reading in a sub-group.
 
int GetIntSG (strg file, strg token, strg group, strg groupS, const bool binary=false)
 For reading in a sub-group.
 
bool GetBoolSG (strg file, strg token, strg group, strg groupS, const bool binary=false)
 For reading in a sub-group.
 
strg GetStringSGI (strg file, strg token, strg group, strg groupS, const bool binary=false)
 From memory.
 
real6 GetNumberSGI (strg file, strg token, strg group, strg groupS, const bool binary=false)
 From memory.
 
int GetIntSGI (strg file, strg token, strg group, strg groupS, const bool binary=false)
 From memory.
 
bool GetBoolSGI (strg file, strg token, strg group, strg groupS, const bool binary=false)
 From memory.
 
uint GroupItemAmount (strg file, strg group, const bool binary=false)
 
uint GroupItemAmountI (strg file, strg group, const bool binary=false)
 From memory.
 
strg GroupItemName (strg file, strg group, uint place, const bool binary=false)
 
strg GroupItemNameI (strg file, strg group, uint place, const bool binary=false)
 From memory.
 
strg GetStringI (strg text, strg token, const bool binary=false)
 Return the tokens value from memory as a std::string.
 
real6 GetNumberI (strg text, strg token, const bool binary=false)
 Return the tokens value from memory as a real6.
 
int GetIntI (strg text, strg token, const bool binary=false)
 Return the tokens value from memory as an int.
 
bool GetBoolI (strg text, strg token, const bool binary=false)
 Return the tokens value from memory as a bool.
 
strg ChangeValueI (strg text, strg token, strg value, const bool binary=false)
 Change a tokens value in memory.
 
Archive * OpenArchive (const char *directory)
 Open ZIP archive.
 
Archive * CreateArchive (const char *directory)
 Creates ZIP archive.
 
ZSTAT GetArchiveFileContents (Archive *z, const char *name)
 Returns a files content from an archive. WARNING: RELEASE contents AFTER USE!! MEMORY LEAK!!
 
void CopyArchiveFileContents (Archive *z, const char *name, const char *newPath, const bool isBinary=false)
 Copies archive file contents.
 
strg CopyArchiveFileContents (Archive *z, const char *name)
 Copies archive file contents.
 
Archive * CloseArchive (Archive *z)
 Closes archive. Changes to archive only take effect once this is called. Memory of written files must be accessable to this process!
 
void AddFileToArchive (Archive *z, const char *filename, const char *content)
 Adds file to archive.
 
void AddBinaryToArchive (Archive *z, const char *filename, const char *content, uint64 size)
 Adds binary file to archive.
 
void CopyFileToArchive (Archive *z, const char *filename, const char *filepath)
 Copies existing file to archive.
 
void RemoveFileFromArchive (Archive *z, const char *filename)
 Removes a file from the archive.
 

Detailed Description

I/O functions

Typedef Documentation

◆ Archive

typedef zip EDR::Archive

Definition at line 77 of file EDR.hpp.

Function Documentation

◆ AddBinaryToArchive()

void EDR::AddBinaryToArchive ( EDR::Archive * z,
const char * filename,
const char * content,
uint64 size )

Adds binary file to archive.

Definition at line 501 of file EDR.cpp.

502{
503 zip_source_t* s;
504 if ((s = zip_source_buffer(z, content, size, 0)) == NULL ||
505 zip_file_add(z, filename, s, 0) < 0) {
506 zip_source_free(s);
507 eConsole::PrintLog("ERROR::EDR::AddFileToZIP", "Error adding File to zip archive!");
508 }
509}
static void PrintLog(eString head, eString msg)
Print a log.
Definition Console.cpp:22

◆ AddFileToArchive()

void EDR::AddFileToArchive ( EDR::Archive * z,
const char * filename,
const char * content )

Adds file to archive.

Definition at line 490 of file EDR.cpp.

491{
492 zip_source_t* s;
493 if ((s = zip_source_buffer(z, content, strlen(content), 0)) == NULL ||
494 zip_file_add(z, filename, s, 0) < 0) {
495 zip_source_free(s);
496 eConsole::PrintLog("ERROR::EDR::AddFileToZIP", "Error adding File to zip archive!");
497 }
498}

◆ ChangeValue()

const uint EDR::ChangeValue ( strg file,
strg token,
strg value,
const bool binary = false )

Change a tokens value.

Definition at line 142 of file EDR.cpp.

143{
144 strg newTok = token;
145 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
146
147 strg newValue = value;
148 std::replace_if(newValue.begin(), newValue.end(), [](char c) { return c == ' '; }, '|');
149
150 std::ifstream _inpfile;
151 _inpfile.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
152 if (!_inpfile)
153 {
154 _inpfile.close();
155 return 0;
156 }
157 strg _content = strg((std::istreambuf_iterator<char>(_inpfile)), std::istreambuf_iterator<char>());
158 _inpfile.close();
159
160 if (_content.find(newTok) != strg::npos)
161 _content.replace(_content.find(newTok), newTok.size() + GetString(file, newTok).size() + 1, newTok + "=" + newValue);
162
163 SetValue(file, _content);
164 return 1;
165}

◆ ChangeValueI()

strg EDR::ChangeValueI ( strg text,
strg token,
strg value,
const bool binary = false )

Change a tokens value in memory.

Definition at line 251 of file EDR.cpp.

252{
253 strg rtVl = text;
254 if (rtVl.find(token) != strg::npos)
255 rtVl.replace(rtVl.find(token), token.size() + GetStringI(rtVl, token).size() + 1, token + "=" + value);
256 return rtVl;
257}
strg GetStringI(strg text, strg token, const bool binary=false)
Return the tokens value from memory as a std::string.
Definition EDR.cpp:168

◆ CloseArchive()

zip * EDR::CloseArchive ( EDR::Archive * z)

Closes archive. Changes to archive only take effect once this is called. Memory of written files must be accessable to this process!

Definition at line 604 of file EDR.cpp.

605{
606 //Close the archive
607 zip_close(z);
608 return z;
609}

◆ ConvertToBinary()

void EDR::ConvertToBinary ( strg & text)

Convert text to binary string.

Definition at line 260 of file EDR.cpp.

261{
262 strg rtBin = "";
263 for (uint i = 0; i < text.length(); i++)
264 {
265 //Convert character to ASCII code
266 int ascii = (int)text[i];
267 strg _tmpBin = "";
268 while (ascii > 0)
269 {
270 if (ascii % 2 == 0)
271 _tmpBin = "0" + _tmpBin;
272 else
273 _tmpBin = "1" + _tmpBin;
274 ascii /= 2;
275 }
276
277 //Pad with zeros to ensure each binary code is 8 bits
278 while (_tmpBin.length() < 8)
279 _tmpBin = "0" + _tmpBin;
280 rtBin += _tmpBin;
281 }
282
283 //Compress
284 strg crtBin;
285 uint zeros = 0;
286 uint ones = 0;
287 bool isCounting0 = false;
288 bool firstCount = false;
289 for (auto& it : rtBin)
290 {
291 if (it == '0')
292 {
293 if (!isCounting0 && firstCount)
294 {
295 isCounting0 = true;
296 crtBin += std::to_string(ones);
297 ones = 0;
298 }
299
300 if (!firstCount)
301 {
302 firstCount = true;
303 crtBin = "0";
304 }
305 zeros += 1;
306 }
307 else if (it == '1')
308 {
309 if (isCounting0 && firstCount)
310 {
311 isCounting0 = false;
312 crtBin += std::to_string(zeros);
313 zeros = 0;
314 }
315
316 if (!firstCount)
317 {
318 firstCount = true;
319 crtBin = "1";
320 }
321 ones += 1;
322 }
323 }
324 text = crtBin;
325 return;
326}

◆ ConvertToText()

void EDR::ConvertToText ( strg & binary)

Convert binary string to text.

Definition at line 329 of file EDR.cpp.

330{
331 //De-Compress
332 strg ucbinary;
333 bool isCounting0 = false;
334 if (binary.at(0) == '0')
335 isCounting0 = true;
336
337 for (auto& it : binary)
338 {
339 uint amount = ::atoi(strg(1, it).c_str());
340 strg out = isCounting0 ? "0" : "1";
341 isCounting0 = !isCounting0;
342
343 for (uint i = 0; i < amount; i++)
344 ucbinary += out;
345 }
346
347 strg rtTxt = "";
348 for (uint i = 0; i < ucbinary.length(); i += 8)
349 {
350 strg byteString = ucbinary.substr(i, 8);
351 int decimal = 0;
352 for (int f = 0; f < byteString.length(); f++)
353 decimal = decimal * 2 + (byteString[f] - '0');
354 char character = (char)decimal;
355 rtTxt += character;
356 }
357 binary = rtTxt;
358 return;
359}

◆ CopyArchiveFileContents() [1/2]

strg EDR::CopyArchiveFileContents ( EDR::Archive * z,
const char * name )

Copies archive file contents.

Definition at line 580 of file EDR.cpp.

581{
582 //Search for the file
583 struct zip_stat st;
584 zip_stat_init(&st);
585 zip_stat(z, name, 0, &st);
586
587 //Alloc memory for its uncompressed contents
588 char* contents = new char[st.size];
589
590 //Read the compressed file
591 zip_file* f = zip_fopen(z, name, 0);
592 zip_fread(f, contents, st.size);
593 zip_fclose(f);
594
595 strg rtStrg = "";
596 for (int i = 0; i < st.size; i++)
597 rtStrg += contents[i];
598
599 delete[] contents;
600 return rtStrg;
601}

◆ CopyArchiveFileContents() [2/2]

void EDR::CopyArchiveFileContents ( EDR::Archive * z,
const char * name,
const char * newPath,
const bool isBinary = false )

Copies archive file contents.

Definition at line 557 of file EDR.cpp.

558{
559 //Search for the file
560 struct zip_stat st;
561 zip_stat_init(&st);
562 zip_stat(z, name, 0, &st);
563
564 //Alloc memory for its uncompressed contents
565 char* contents = new char[st.size];
566
567 //Read the compressed file
568 zip_file* f = zip_fopen(z, name, 0);
569 zip_fread(f, contents, st.size);
570 zip_fclose(f);
571
572 std::ofstream endFile(newPath, isBinary ? (std::ios::out | std::ios::binary) : std::ios::out);
573 endFile.write(contents, st.size);
574 endFile.close();
575 delete[] contents;
576 return;
577}

◆ CopyFileToArchive()

void EDR::CopyFileToArchive ( EDR::Archive * z,
const char * filename,
const char * filepath )

Copies existing file to archive.

Definition at line 512 of file EDR.cpp.

513{
514 zip_source_t* imageSource = zip_source_file(z, filepath, 0, 0);
515 zip_file_add(z, filename, imageSource, ZIP_FL_ENC_UTF_8);
516}

◆ CreateArchive()

EDR::Archive * EDR::CreateArchive ( const char * directory)

Creates ZIP archive.

Definition at line 476 of file EDR.cpp.

477{
478 //Open ZIP archive
479 int err = 0;
480 zip* z = zip_open(directory, ZIP_CREATE, &err);
481
482 if (err == ZIP_ER_NOZIP) {
483 eConsole::PrintLog("EDR::CreateZIPArchive", "Directory is not a ZIP archive.");
484 return {};
485 }
486 return z;
487}

◆ CreateDirectoryExt()

void EDR::CreateDirectoryExt ( const char * dir)

Creates a directory on drive.

Definition at line 378 of file EDR.cpp.

379{
380 //Creating File
381 if (_mkdir(dir) == -1) {
382 eConsole::PrintLog(eString("EDR::CreateDirectory"), strerror(errno));
383 return;
384 }
385 else {
386 eConsole::PrintLog("EDR::CreateDirectory", "Successfully created new directory.");
387 }
388 return;
389}

◆ DeleteDirectory()

void EDR::DeleteDirectory ( const char * dir)

Removes a directory from drive.

Definition at line 392 of file EDR.cpp.

393{
394 if (_rmdir(dir) == -1) {
395 eConsole::PrintLog("EDR::DeleteDirectory", strerror(errno));
396 return;
397 }
398 else {
399 eConsole::PrintLog("EDR::DeleteDirectory", "Successfully deleted directory.");
400 }
401 return;
402}

◆ FileExists()

bool EDR::FileExists ( const char * path)

Definition at line 611 of file EDR.cpp.

612{
613 std::ifstream file(path);
614 if (file.is_open()) {
615 file.close();
616 return true;
617 }
618 file.close();
619 return false;
620}

◆ GetArchiveFileContents()

EDR::ZSTAT EDR::GetArchiveFileContents ( EDR::Archive * z,
const char * name )

Returns a files content from an archive. WARNING: RELEASE contents AFTER USE!! MEMORY LEAK!!

Definition at line 537 of file EDR.cpp.

538{
539 //Search for the file
540 struct zip_stat st;
541 zip_stat_init(&st);
542 zip_stat(z, name, 0, &st);
543
544 //Alloc memory for its uncompressed contents
545 char* contents = new char[st.size];
546
547 //Read the compressed file
548 zip_file* f = zip_fopen(z, name, 0);
549 zip_fread(f, contents, st.size);
550 zip_fclose(f);
551
552 //WARNING: RELEASE contents AFTER USE!! MEMORY LEAK!!
553 return ZSTAT(contents, static_cast<zip_uint16_t>(st.size));
554}

◆ GetBool()

bool EDR::GetBool ( strg file,
strg token,
const bool binary = false )

Return the tokens value as a bool.

Definition at line 91 of file EDR.cpp.

92{
93 strg tok;
94 std::ifstream File;
95 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
96 if (!File)
97 {
98 File.close();
99 return false;
100 }
101 strg newTok = token;
102 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
103 while (File >> tok)
104 {
105 if (newTok == tok.substr(0, tok.find("="))) {
106 strg tuk = tok.replace(tok.find(newTok), newTok.length() + 1, "");
107 if (tuk == "false" || tuk == "null" || tuk == "NULL" || tuk == "Null" || tuk == "0") {
108 File.close();
109 return false;
110 }
111 else if (tuk == "true" || tuk == "1") {
112 File.close();
113 return true;
114 }
115 else {
116 File.close();
117 return false;
118 }
119 }
120 }
121 return false;
122}

◆ GetBoolG()

bool EDR::GetBoolG ( strg file,
strg token,
strg group,
const bool binary = false )

For reading in a group.

Definition at line 749 of file EDR.cpp.

750{
751 strg tok;
752 std::ifstream File;
753 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
754 if (!File)
755 return false;
756 bool isGroup = false;
757
758 strg newTok = token;
759 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
760 strg newGroup = group;
761 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
762 while (File >> tok)
763 {
764 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
765 isGroup = true;
766
767 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
768 isGroup = false;
769
770 if (isGroup)
771 {
772 if (newTok == tok.substr(0, tok.find("="))) {
773 strg tuk = tok.replace(tok.find(newTok), newTok.length() + 1, "");
774 if (tuk == "false" || tuk == "null" || tuk == "NULL" || tuk == "Null" || tuk == "0") {
775 File.close();
776 return false;
777 }
778 else if (tuk == "true" || tuk == "1") {
779 File.close();
780 return true;
781 }
782 else {
783 File.close();
784 return false;
785 }
786 }
787 }
788 }
789 return false;
790}

◆ GetBoolGI()

bool EDR::GetBoolGI ( strg file,
strg token,
strg group,
const bool binary = false )

From memory.

Definition at line 1189 of file EDR.cpp.

1190{
1191 bool isGroup = false;
1192
1193 strg newTok = token;
1194 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
1195 strg newGroup = group;
1196 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
1197 std::istringstream iss(file);
1198 strg tok = "";
1199 while (iss >> tok)
1200 {
1201 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
1202 isGroup = true;
1203
1204 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
1205 isGroup = false;
1206
1207 if (isGroup)
1208 {
1209 if (newTok == tok.substr(0, tok.find("="))) {
1210 strg tuk = tok.replace(tok.find(newTok), newTok.length() + 1, "");
1211 if (tuk == "false" || tuk == "null" || tuk == "NULL" || tuk == "Null" || tuk == "0") {
1212 return false;
1213 }
1214 else if (tuk == "true" || tuk == "1") {
1215 return true;
1216 }
1217 else {
1218 return false;
1219 }
1220 }
1221 }
1222 }
1223 return false;
1224}

◆ GetBoolI()

bool EDR::GetBoolI ( strg text,
strg token,
const bool binary = false )

Return the tokens value from memory as a bool.

Definition at line 229 of file EDR.cpp.

230{
231 std::istringstream iss(text);
232 strg word = "";
233 while (iss >> word)
234 {
235 strg ww = word.substr(0, word.find("="));
236 std::replace_if(ww.begin(), ww.end(), [](char c) { return c == ' '; }, '|');
237 if (token == ww) {
238 strg tuk = word.replace(word.find(token), token.length() + 1, "");
239 if (tuk == "false" || tuk == "null" || tuk == "NULL" || tuk == "Null" || tuk == "0")
240 return false;
241 else if (tuk == "true" || tuk == "1")
242 return true;
243 else
244 return false;
245 }
246 }
247 return true;
248}

◆ GetBoolSG()

bool EDR::GetBoolSG ( strg file,
strg token,
strg group,
strg groupS,
const bool binary = false )

For reading in a sub-group.

Definition at line 922 of file EDR.cpp.

923{
924 strg tok;
925 std::ifstream File;
926 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
927 if (!File)
928 return false;
929 bool isGroups = false;
930 bool isGroup = false;
931
932 strg newTok = token;
933 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
934 strg newGroup = group;
935 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
936 strg newGroups = groupS;
937 std::replace_if(newGroups.begin(), newGroups.end(), [](char c) { return c == ' '; }, '|');
938 while (File >> tok)
939 {
940 if (tok.find("<" + newGroups + ">") != strg::npos && !isGroups && isGroup)
941 isGroups = true;
942
943 if (tok.find("</" + newGroups + ">") != strg::npos && isGroups && isGroup)
944 isGroups = false;
945
946 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
947 isGroup = true;
948
949 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
950 isGroup = false;
951
952 if (isGroup && isGroups)
953 {
954 if (newTok == tok.substr(0, tok.find("="))) {
955 strg tuk = tok.replace(tok.find(newTok), newTok.length() + 1, "");
956 if (tuk == "false" || tuk == "null" || tuk == "NULL" || tuk == "Null" || tuk == "0") {
957 File.close();
958 return false;
959 }
960 else if (tuk == "true" || tuk == "1") {
961 File.close();
962 return true;
963 }
964 else {
965 File.close();
966 return false;
967 }
968 }
969 }
970 }
971 return false;
972}

◆ GetBoolSGI()

bool EDR::GetBoolSGI ( strg file,
strg token,
strg group,
strg groupS,
const bool binary = false )

From memory.

Definition at line 1343 of file EDR.cpp.

1344{
1345 bool isGroups = false;
1346 bool isGroup = false;
1347
1348 strg newTok = token;
1349 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
1350 strg newGroup = group;
1351 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
1352 strg newGroups = groupS;
1353 std::replace_if(newGroups.begin(), newGroups.end(), [](char c) { return c == ' '; }, '|');
1354 std::istringstream iss(file);
1355 strg tok = "";
1356 while (iss >> tok)
1357 {
1358 if (tok.find("<" + newGroups + ">") != strg::npos && !isGroups && isGroup)
1359 isGroups = true;
1360
1361 if (tok.find("</" + newGroups + ">") != strg::npos && isGroups && isGroup)
1362 isGroups = false;
1363
1364 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
1365 isGroup = true;
1366
1367 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
1368 isGroup = false;
1369
1370 if (isGroup && isGroups)
1371 {
1372 if (newTok == tok.substr(0, tok.find("="))) {
1373 strg tuk = tok.replace(tok.find(newTok), newTok.length() + 1, "");
1374 if (tuk == "false" || tuk == "null" || tuk == "NULL" || tuk == "Null" || tuk == "0") {
1375 return false;
1376 }
1377 else if (tuk == "true" || tuk == "1") {
1378 return true;
1379 }
1380 else {
1381 return false;
1382 }
1383 }
1384 }
1385 }
1386 return false;
1387}

◆ GetContext()

strg EDR::GetContext ( strg filePath,
const bool binary = false )

Returns a files content.

Definition at line 362 of file EDR.cpp.

363{
364 std::ifstream File(filePath, binary ? std::ios::binary | std::ios::in : std::ios::in);
365 strg rtVl = strg((std::istreambuf_iterator<char>(File)), std::istreambuf_iterator<char>());
366 File.close();
367 return rtVl;
368}

◆ GetFilesInDir()

std::vector< strg > EDR::GetFilesInDir ( strg dir,
const int nt )

nt: 0 = full; 1 = name; 2 = extension;

Definition at line 625 of file EDR.cpp.

626{
627 if (std::filesystem::exists(dir))
628 {
629 std::vector<strg> rtVl;
630 for (const auto& entry : std::filesystem::directory_iterator(dir))
631 {
632 if (entry.is_regular_file())
633 {
634 strg pb = entry.path().filename().string();
635 switch (nt)
636 {
637 case 1: {pb = entry.path().stem().string(); }break;
638 case 2: {pb = entry.path().extension().string(); }break;
639 }
640 rtVl.push_back(pb);
641 }
642 }
643 return rtVl;
644 }
645 return {};
646}

◆ GetInt()

int EDR::GetInt ( strg file,
strg token,
const bool binary = false )

Return the tokens value as an int.

Definition at line 67 of file EDR.cpp.

68{
69 strg tok;
70 std::ifstream File;
71 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
72 if (!File)
73 {
74 File.close();
75 return 0;
76 }
77
78 strg newTok = token;
79 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
80 while (File >> tok)
81 {
82 if (newTok == tok.substr(0, tok.find("="))) {
83 File.close();
84 return ::atoi(tok.replace(tok.find(newTok), newTok.length() + 1, "").c_str());
85 }
86 }
87 return 0;
88}

◆ GetIntG()

int EDR::GetIntG ( strg file,
strg token,
strg group,
const bool binary = false )

For reading in a group.

Definition at line 716 of file EDR.cpp.

717{
718 strg tok;
719 std::ifstream File;
720 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
721 if (!File)
722 return 0;
723
724 strg newTok = token;
725 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
726 strg newGroup = group;
727 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
728 bool isGroup = false;
729 while (File >> tok)
730 {
731 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
732 isGroup = true;
733
734 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
735 isGroup = false;
736
737 if (isGroup)
738 {
739 if (newTok == tok.substr(0, tok.find("="))) {
740 File.close();
741 return ::atoi(tok.replace(tok.find(newTok), newTok.length() + 1, "").c_str());
742 }
743 }
744 }
745 return 0;
746}

◆ GetIntGI()

int EDR::GetIntGI ( strg file,
strg token,
strg group,
const bool binary = false )

From memory.

Definition at line 1161 of file EDR.cpp.

1162{
1163 strg newTok = token;
1164 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
1165 strg newGroup = group;
1166 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
1167 bool isGroup = false;
1168 std::istringstream iss(file);
1169 strg tok = "";
1170 while (iss >> tok)
1171 {
1172 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
1173 isGroup = true;
1174
1175 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
1176 isGroup = false;
1177
1178 if (isGroup)
1179 {
1180 if (newTok == tok.substr(0, tok.find("="))) {
1181 return ::atoi(tok.replace(tok.find(newTok), newTok.length() + 1, "").c_str());
1182 }
1183 }
1184 }
1185 return 0;
1186}

◆ GetIntI()

int EDR::GetIntI ( strg text,
strg token,
const bool binary = false )

Return the tokens value from memory as an int.

Definition at line 214 of file EDR.cpp.

215{
216 std::istringstream iss(text);
217 strg word = "";
218 while (iss >> word)
219 {
220 strg ww = word.substr(0, word.find("="));
221 std::replace_if(ww.begin(), ww.end(), [](char c) { return c == ' '; }, '|');
222 if (token == ww)
223 return ::atoi(word.replace(word.find(token), token.length() + 1, "").c_str());
224 }
225 return 0;
226}

◆ GetIntSG()

int EDR::GetIntSG ( strg file,
strg token,
strg group,
strg groupS,
const bool binary = false )

For reading in a sub-group.

Definition at line 880 of file EDR.cpp.

881{
882 strg tok;
883 std::ifstream File;
884 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
885 if (!File)
886 return 0;
887 bool isGroups = false;
888 bool isGroup = false;
889
890 strg newTok = token;
891 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
892 strg newGroup = group;
893 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
894 strg newGroups = groupS;
895 std::replace_if(newGroups.begin(), newGroups.end(), [](char c) { return c == ' '; }, '|');
896 while (File >> tok)
897 {
898 if (tok.find("<" + newGroups + ">") != strg::npos && !isGroups && isGroup)
899 isGroups = true;
900
901 if (tok.find("</" + newGroups + ">") != strg::npos && isGroups && isGroup)
902 isGroups = false;
903
904 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
905 isGroup = true;
906
907 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
908 isGroup = false;
909
910 if (isGroup && isGroups)
911 {
912 if (newTok == tok.substr(0, tok.find("="))) {
913 File.close();
914 return ::atoi(tok.replace(tok.find(newTok), newTok.length() + 1, "").c_str());
915 }
916 }
917 }
918 return 0;
919}

◆ GetIntSGI()

int EDR::GetIntSGI ( strg file,
strg token,
strg group,
strg groupS,
const bool binary = false )

From memory.

Definition at line 1305 of file EDR.cpp.

1306{
1307 bool isGroups = false;
1308 bool isGroup = false;
1309
1310 strg newTok = token;
1311 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
1312 strg newGroup = group;
1313 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
1314 strg newGroups = groupS;
1315 std::replace_if(newGroups.begin(), newGroups.end(), [](char c) { return c == ' '; }, '|');
1316 std::istringstream iss(file);
1317 strg tok = "";
1318 while (iss >> tok)
1319 {
1320 if (tok.find("<" + newGroups + ">") != strg::npos && !isGroups && isGroup)
1321 isGroups = true;
1322
1323 if (tok.find("</" + newGroups + ">") != strg::npos && isGroups && isGroup)
1324 isGroups = false;
1325
1326 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
1327 isGroup = true;
1328
1329 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
1330 isGroup = false;
1331
1332 if (isGroup && isGroups)
1333 {
1334 if (newTok == tok.substr(0, tok.find("="))) {
1335 return ::atoi(tok.replace(tok.find(newTok), newTok.length() + 1, "").c_str());
1336 }
1337 }
1338 }
1339 return 0;
1340}

◆ GetNumber()

real6 EDR::GetNumber ( strg file,
strg token,
const bool binary = false )

Return the tokens value as a real6.

Definition at line 44 of file EDR.cpp.

45{
46 strg tok;
47 std::ifstream File;
48 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
49 if (!File)
50 {
51 File.close();
52 return 0;
53 }
54 strg newTok = token;
55 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
56 while (File >> tok)
57 {
58 if (newTok == tok.substr(0, tok.find("="))) {
59 File.close();
60 return ::atof(tok.replace(tok.find(newTok), newTok.length() + 1, "").c_str());
61 }
62 }
63 return 0;
64}

◆ GetNumberG()

real6 EDR::GetNumberG ( strg file,
strg token,
strg group,
const bool binary = false )

For reading in a group.

Definition at line 684 of file EDR.cpp.

685{
686 strg tok;
687 std::ifstream File;
688 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
689 if (!File)
690 return 0;
691 bool isGroup = false;
692 strg newTok = token;
693 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
694 strg newGroup = group;
695 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
696 while (File >> tok)
697 {
698 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
699 isGroup = true;
700
701 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
702 isGroup = false;
703
704 if (isGroup)
705 {
706 if (newTok == tok.substr(0, tok.find("="))) {
707 File.close();
708 return ::atof(tok.replace(tok.find(newTok), newTok.length() + 1, "").c_str());
709 }
710 }
711 }
712 return 0;
713}

◆ GetNumberGI()

real6 EDR::GetNumberGI ( strg file,
strg token,
strg group,
const bool binary = false )

From memory.

Definition at line 1133 of file EDR.cpp.

1134{
1135 bool isGroup = false;
1136 strg newTok = token;
1137 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
1138 strg newGroup = group;
1139 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
1140 std::istringstream iss(file);
1141 strg tok = "";
1142 while (iss >> tok)
1143 {
1144 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
1145 isGroup = true;
1146
1147 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
1148 isGroup = false;
1149
1150 if (isGroup)
1151 {
1152 if (newTok == tok.substr(0, tok.find("="))) {
1153 return ::atof(tok.replace(tok.find(newTok), newTok.length() + 1, "").c_str());
1154 }
1155 }
1156 }
1157 return 0;
1158}

◆ GetNumberI()

real6 EDR::GetNumberI ( strg text,
strg token,
const bool binary = false )

Return the tokens value from memory as a real6.

Definition at line 196 of file EDR.cpp.

197{
198 std::istringstream iss(text);
199 strg word = "";
200 while (iss >> word)
201 {
202 strg ww = word.substr(0, word.find("="));
203 std::replace_if(ww.begin(), ww.end(), [](char c) { return c == ' '; }, '|');
204 if (token == ww) {
205 iss.clear();
206 return ::atof(word.replace(word.find(token), token.length() + 1, "").c_str());
207 }
208 }
209 iss.clear();
210 return 0;
211}

◆ GetNumberSG()

real6 EDR::GetNumberSG ( strg file,
strg token,
strg group,
strg groupS,
const bool binary = false )

For reading in a sub-group.

Definition at line 838 of file EDR.cpp.

839{
840 strg tok;
841 std::ifstream File;
842 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
843 if (!File)
844 return 0;
845 bool isGroups = false;
846 bool isGroup = false;
847
848 strg newTok = token;
849 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
850 strg newGroup = group;
851 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
852 strg newGroups = groupS;
853 std::replace_if(newGroups.begin(), newGroups.end(), [](char c) { return c == ' '; }, '|');
854 while (File >> tok)
855 {
856 if (tok.find("<" + newGroups + ">") != strg::npos && !isGroups && isGroup)
857 isGroups = true;
858
859 if (tok.find("</" + newGroups + ">") != strg::npos && isGroups && isGroup)
860 isGroups = false;
861
862 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
863 isGroup = true;
864
865 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
866 isGroup = false;
867
868 if (isGroup && isGroups)
869 {
870 if (newTok == tok.substr(0, tok.find("="))) {
871 File.close();
872 return ::atof(tok.replace(tok.find(newTok), newTok.length() + 1, "").c_str());
873 }
874 }
875 }
876 return 0;
877}

◆ GetNumberSGI()

real6 EDR::GetNumberSGI ( strg file,
strg token,
strg group,
strg groupS,
const bool binary = false )

From memory.

Definition at line 1267 of file EDR.cpp.

1268{
1269 bool isGroups = false;
1270 bool isGroup = false;
1271
1272 strg newTok = token;
1273 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
1274 strg newGroup = group;
1275 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
1276 strg newGroups = groupS;
1277 std::replace_if(newGroups.begin(), newGroups.end(), [](char c) { return c == ' '; }, '|');
1278 std::istringstream iss(file);
1279 strg tok = "";
1280 while (iss >> tok)
1281 {
1282 if (tok.find("<" + newGroups + ">") != strg::npos && !isGroups && isGroup)
1283 isGroups = true;
1284
1285 if (tok.find("</" + newGroups + ">") != strg::npos && isGroups && isGroup)
1286 isGroups = false;
1287
1288 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
1289 isGroup = true;
1290
1291 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
1292 isGroup = false;
1293
1294 if (isGroup && isGroups)
1295 {
1296 if (newTok == tok.substr(0, tok.find("="))) {
1297 return ::atof(tok.replace(tok.find(newTok), newTok.length() + 1, "").c_str());
1298 }
1299 }
1300 }
1301 return 0;
1302}

◆ GetString()

strg EDR::GetString ( strg file,
strg token,
const bool binary = false )

Return the tokens value as a std::string.

Definition at line 13 of file EDR.cpp.

14{
15 strg tok;
16 std::ifstream File;
17 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
18 if (!File)
19 {
20 File.close();
21 return "Error: Could not find '" + file + "'";
22 }
23
24 strg newTok = token;
25 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
26 while (File >> tok)
27 {
28 if (newTok == tok.substr(0, tok.find("="))) {
29 File.close();
30 strg tuk = tok.replace(tok.find(newTok), newTok.length() + 1, "");
31 std::replace_if(tuk.begin(), tuk.end(), [](char c) { return c == '|'; }, ' ');
32 tok.clear();
33 newTok.clear();
34 return tuk;
35 }
36 }
37 File.close();
38 tok.clear();
39 newTok.clear();
40 return "";
41}

◆ GetStringG()

strg EDR::GetStringG ( strg file,
strg token,
strg group,
const bool binary = false )

For reading in a group.

Definition at line 649 of file EDR.cpp.

650{
651 strg tok;
652 std::ifstream File;
653 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
654 if (!File)
655 return "Error: Could not find '" + file + "'";
656 bool isGroup = false;
657 strg newTok = token;
658 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
659 strg newGroup = group;
660 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
661 while (File >> tok)
662 {
663 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
664 isGroup = true;
665
666 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
667 isGroup = false;
668
669 if (isGroup)
670 {
671 if (newTok == tok.substr(0, tok.find("="))) {
672 strg tuk = tok.replace(tok.find(newTok), newTok.length() + 1, "");
673 std::replace_if(tuk.begin(), tuk.end(), [](char c) { return c == '|'; }, ' ');
674 File.close();
675 return tuk;
676 }
677 }
678 }
679 File.close();
680 return "";
681}

◆ GetStringGI()

strg EDR::GetStringGI ( strg file,
strg token,
strg group,
const bool binary = false )

From memory.

Definition at line 1103 of file EDR.cpp.

1104{
1105 bool isGroup = false;
1106 strg newTok = token;
1107 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
1108 strg newGroup = group;
1109 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
1110 std::istringstream iss(file);
1111 strg tok = "";
1112 while (iss >> tok)
1113 {
1114 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
1115 isGroup = true;
1116
1117 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
1118 isGroup = false;
1119
1120 if (isGroup)
1121 {
1122 if (newTok == tok.substr(0, tok.find("="))) {
1123 strg tuk = tok.replace(tok.find(newTok), newTok.length() + 1, "");
1124 std::replace_if(tuk.begin(), tuk.end(), [](char c) { return c == '|'; }, ' ');
1125 return tuk;
1126 }
1127 }
1128 }
1129 return "";
1130}

◆ GetStringI()

strg EDR::GetStringI ( strg text,
strg token,
const bool binary = false )

Return the tokens value from memory as a std::string.

Definition at line 168 of file EDR.cpp.

169{
170 std::istringstream iss(text);
171 strg word = "";
172 while (iss >> word)
173 {
174 strg ww = word.substr(0, word.find("="));
175 std::replace_if(ww.begin(), ww.end(), [](char c) { return c == ' '; }, '|');
176 if (token == ww) {
177 strg tuk = word.replace(word.find(token), token.length() + 1, "");
178 if (tuk.find("'") != strg::npos)
179 {
180 iss.clear();
181 word.clear();
182 return tuk.replace(tuk.find("'"), 1, " ");
183 }
184 else
185 {
186 iss.clear();
187 word.clear();
188 return tuk;
189 }
190 }
191 }
192 return "";
193}

◆ GetStringSG()

strg EDR::GetStringSG ( strg file,
strg token,
strg group,
strg groupS,
const bool binary = false )

For reading in a sub-group.

Definition at line 793 of file EDR.cpp.

794{
795 strg tok;
796 std::ifstream File;
797 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
798 if (!File)
799 return "Error: Could not find '" + file + "'";
800 bool isGroups = false;
801 bool isGroup = false;
802
803 strg newTok = token;
804 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
805 strg newGroup = group;
806 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
807 strg newGroups = groupS;
808 std::replace_if(newGroups.begin(), newGroups.end(), [](char c) { return c == ' '; }, '|');
809 while (File >> tok)
810 {
811 if (tok.find("<" + newGroups + ">") != strg::npos && !isGroups && isGroup)
812 isGroups = true;
813
814 if (tok.find("</" + newGroups + ">") != strg::npos && isGroups && isGroup)
815 isGroups = false;
816
817 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
818 isGroup = true;
819
820 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
821 isGroup = false;
822
823 if (isGroup && isGroups)
824 {
825 if (newTok == tok.substr(0, tok.find("="))) {
826 File.close();
827 strg tuk = tok.replace(tok.find(newTok), newTok.length() + 1, "");
828 std::replace_if(tuk.begin(), tuk.end(), [](char c) { return c == '|'; }, ' ');
829 return tuk;
830 }
831 }
832 }
833 File.close();
834 return "";
835}

◆ GetStringSGI()

strg EDR::GetStringSGI ( strg file,
strg token,
strg group,
strg groupS,
const bool binary = false )

From memory.

Definition at line 1227 of file EDR.cpp.

1228{
1229 bool isGroups = false;
1230 bool isGroup = false;
1231
1232 strg newTok = token;
1233 std::replace_if(newTok.begin(), newTok.end(), [](char c) { return c == ' '; }, '|');
1234 strg newGroup = group;
1235 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
1236 strg newGroups = groupS;
1237 std::replace_if(newGroups.begin(), newGroups.end(), [](char c) { return c == ' '; }, '|');
1238 std::istringstream iss(file);
1239 strg tok = "";
1240 while (iss >> tok)
1241 {
1242 if (tok.find("<" + newGroups + ">") != strg::npos && !isGroups && isGroup)
1243 isGroups = true;
1244
1245 if (tok.find("</" + newGroups + ">") != strg::npos && isGroups && isGroup)
1246 isGroups = false;
1247
1248 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
1249 isGroup = true;
1250
1251 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
1252 isGroup = false;
1253
1254 if (isGroup && isGroups)
1255 {
1256 if (newTok == tok.substr(0, tok.find("="))) {
1257 strg tuk = tok.replace(tok.find(newTok), newTok.length() + 1, "");
1258 std::replace_if(tuk.begin(), tuk.end(), [](char c) { return c == '|'; }, ' ');
1259 return tuk;
1260 }
1261 }
1262 }
1263 return "";
1264}

◆ GroupItemAmount()

uint EDR::GroupItemAmount ( strg file,
strg group,
const bool binary = false )

Definition at line 975 of file EDR.cpp.

976{
977 strg tok;
978 std::ifstream File;
979 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
980 if (!File)
981 return 0;
982
983 uint rtAmount = 0;
984 bool isGroup = false;
985 strg newGroup = group;
986 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
987 while (File >> tok)
988 {
989 if (tok.find("<") != strg::npos && tok.find("</") == strg::npos && isGroup)
990 rtAmount += 1;
991
992 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
993 isGroup = true;
994
995 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
996 {
997 isGroup = false;
998 break;
999 }
1000 }
1001 return rtAmount;
1002}

◆ GroupItemAmountI()

uint EDR::GroupItemAmountI ( strg file,
strg group,
const bool binary = false )

From memory.

Definition at line 1005 of file EDR.cpp.

1006{
1007 uint rtAmount = 0;
1008 bool isGroup = false;
1009 strg newGroup = group;
1010 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
1011
1012 std::istringstream iss(file);
1013 strg tok = "";
1014 while (iss >> tok)
1015 {
1016 if (tok.find("<") != strg::npos && isGroup && tok.find("</") == strg::npos)
1017 rtAmount += 1;
1018
1019 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
1020 isGroup = true;
1021
1022 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
1023 {
1024 isGroup = false;
1025 break;
1026 }
1027 }
1028 return rtAmount;
1029}

◆ GroupItemName()

strg EDR::GroupItemName ( strg file,
strg group,
uint place,
const bool binary = false )

Definition at line 1031 of file EDR.cpp.

1032{
1033 strg tok;
1034 std::ifstream File;
1035 File.open(file, binary ? std::ios::binary | std::ios::in : std::ios::in);
1036 if (!File)
1037 return "ERROR: FILE NOT FOUND!";
1038
1039 uint rtAmount = 0;
1040 bool isGroup = false;
1041 strg newGroup = group;
1042 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
1043 while (File >> tok)
1044 {
1045 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
1046 {
1047 isGroup = false;
1048 break;
1049 }
1050
1051 if (tok.find("<") != strg::npos && tok.find("</") == strg::npos && isGroup)
1052 {
1053 if (rtAmount == place)
1054 {
1055 tok = tok.replace(tok.begin(), tok.begin() + 1, "");
1056 tok = tok.replace(tok.end() - 1, tok.end(), "");
1057 return tok;
1058 }
1059 rtAmount += 1;
1060 }
1061
1062 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
1063 isGroup = true;
1064 }
1065 return "";
1066}

◆ GroupItemNameI()

strg EDR::GroupItemNameI ( strg file,
strg group,
uint place,
const bool binary = false )

From memory.

Definition at line 1069 of file EDR.cpp.

1070{
1071 uint rtAmount = 0;
1072 bool isGroup = false;
1073 strg newGroup = group;
1074 std::replace_if(newGroup.begin(), newGroup.end(), [](char c) { return c == ' '; }, '|');
1075 std::istringstream iss(file);
1076 strg tok = "";
1077 while (iss >> tok)
1078 {
1079 if (tok.find("<") != strg::npos && isGroup && tok.find("</") == strg::npos)
1080 {
1081 if (rtAmount == place)
1082 {
1083 tok = tok.replace(tok.begin(), tok.begin() + 1, "");
1084 tok = tok.replace(tok.end() - 1, tok.end(), "");
1085 return tok;
1086 }
1087 rtAmount += 1;
1088 }
1089
1090 if (tok.find("<" + newGroup + ">") != strg::npos && !isGroup)
1091 isGroup = true;
1092
1093 if (tok.find("</" + newGroup + ">") != strg::npos && isGroup)
1094 {
1095 isGroup = false;
1096 break;
1097 }
1098 }
1099 return "";
1100}

◆ OpenArchive()

EDR::Archive * EDR::OpenArchive ( const char * directory)

Open ZIP archive.

Definition at line 462 of file EDR.cpp.

463{
464 //Open ZIP archive
465 int err = 0;
466 zip* z = zip_open(directory, 0, &err);
467
468 if (err == ZIP_ER_NOZIP) {
469 eConsole::PrintLog("EDR::OpenZIPArchive", "Directory is not a ZIP archive.");
470 return {};
471 }
472 return z;
473}

◆ ReadBinary()

strg EDR::ReadBinary ( const char * dir)

Read binary text from drive.

Definition at line 427 of file EDR.cpp.

428{
429 strg rtVl;
430 std::ifstream file(dir, std::ios::in | std::ios::binary);
431 uint64 size = 0;
432 file.read((char*)&size, sizeof(size));
433 rtVl.resize(size);
434 file.read(&rtVl[0], size);
435 file.close();
436 return rtVl;
437}

◆ ReadBinaryToString()

strg EDR::ReadBinaryToString ( strg & content)

Read binary text from memory.

Definition at line 450 of file EDR.cpp.

451{
452 strg rtVl;
453 std::istringstream iss(content, std::ios::in | std::ios::binary);
454 uint64 size = 0;
455 iss.read(reinterpret_cast<char*>(&size), sizeof(size));
456 rtVl.resize(size);
457 iss.read(&rtVl[0], size);
458 return rtVl;
459}

◆ RemoveFile()

void EDR::RemoveFile ( const char * filePath)

Removes a file from the drive.

Definition at line 371 of file EDR.cpp.

372{
373 remove(filePath);
374 return;
375}

◆ RemoveFileFromArchive()

void EDR::RemoveFileFromArchive ( EDR::Archive * z,
const char * filename )

Removes a file from the archive.

Definition at line 519 of file EDR.cpp.

520{
521 zip_int64_t index = zip_name_locate(z, filename, 0);
522 if (index < 0)
523 {
524 eConsole::PrintLog("ERROR::EDR::RemoveFileFromZIP", "Failed to locate file in ZIP Archive.");
526 return;
527 }
528
529 if (zip_delete(z, static_cast<zip_uint64_t>(index)) < 0)
530 {
531 eConsole::PrintLog("ERROR::EDR::RemoveFileFromZIP", "Failed to delete file from ZIP Archive.");
533 }
534}
static void WriteToDisk()
Write the console text to a crash file called 'CRASH.log'.
Definition Console.cpp:40

◆ SetValue()

const uint EDR::SetValue ( strg file,
strg value,
const bool binary = false )

Set a tokens value.

Definition at line 125 of file EDR.cpp.

126{
127 strg tok;
128 std::ofstream File;
129 File.open(file, binary ? std::ios::binary | std::ios::out : std::ios::out);
130 if (!File)
131 {
132 File.close();
133 return 0;
134 }
135 File.clear();
136 File << value;
137 File.close();
138 return 1;
139}

◆ WriteBinary()

void EDR::WriteBinary ( const char * dir,
strg content )

Write binary text to drive.

Definition at line 416 of file EDR.cpp.

417{
418 std::ofstream file(dir, std::ios::out | std::ios::binary);
419 uint64 size = content.size();
420 file.write((char*)&size, sizeof(size));
421 file.write(&content[0], size);
422 file.close();
423 return;
424}

◆ WriteBinaryToString()

strg EDR::WriteBinaryToString ( strg & content)

Write binary text to memory.

Definition at line 440 of file EDR.cpp.

441{
442 std::ostringstream oss(std::ios::out | std::ios::binary);
443 uint64_t size = content.size();
444 oss.write(reinterpret_cast<const char*>(&size), sizeof(size));
445 oss.write(content.data(), size);
446 return oss.str();
447}

◆ WriteFile()

void EDR::WriteFile ( const char * dir,
strg content )

Write a file to drive.

Definition at line 405 of file EDR.cpp.

406{
407 strg tok;
408 std::ofstream File(dir);
409 File.clear();
410 File << content;
411 File.close();
412 return;
413}