Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program by RunAwayScientist on 9/8/2016
- // PERM: Free to re-distribute and edit.
- // NOTE:
- // DESC: Program will replace one-for-one the
- // gearkits in /Inventroy/MercStartingGear.xml with a standard 5 kits defined
- // in ReplaceWith.txt
- // REQUIREMENTS:
- // Input.txt
- // ReplaceWith.txt
- // CURRENT SETTINGS: Program set to read from input.txt and create a full MercStartingGear.xml
- // in the same folder as the program. Reads from Strings defined in this
- // .cpp to get its replacement information.
- // EXEC:
- // 0. Simple loop that counts to 5, replacing and cutting between <GEARKIT>
- // XML tags. Strings replace1, replace2, replace3, replace4, and replace5 correspond
- // to the first, second, third, fourth, and fifth gearkits.
- // 1. Track two cursors. Use this to find strings between <GEARKIT> delineators
- // then write this info to output string. Then add the replacement string, jump to
- // next <GEARKIT> and substring in the last and beginning cursor. (DONE USING REPLACETAG METHOD)
- // INSTRUCTIONS (FULL):
- //
- // 1. Place your CURRENT MercStartingGear.xml content into Input.txt as raw text.
- //
- // 2. Place your desired gearkit XML replacement into ReplaceWith.txt
- //
- // 3. Run the program. Wait until it finishes. If errors, check source code and recompile or post on
- // Bear Pits forums.
- //
- // 4. Take finished MercStartingGear.xml and replace your old file with it.
- #include <iostream>
- #include <algorithm>
- #include <ctime>
- #include <cctype>
- #include <ctype.h>
- #include <cstdlib>
- #include <fstream>
- #include <string>
- #include <strings.h>
- #include <vector>
- #include <dirent.h>
- #include <stdio.h>
- #include <locale>
- #include <sys/types.h>
- #include <stdlib.h>
- using namespace std;
- string tempS1 = "";
- string tempS2 = "";
- string tempS3 = "";
- string tempS4 = "";
- string tempS5 = "";
- string currentFile = "blarg";
- char tempC1[700]; // Temp buffer before transfer to tempS1
- int tempI1 = 0; // Iterator used in all loops
- int tempI2 = 0; // Count replace char total
- int tempI3 = 0; //Left comma location
- int tempI4 = 0; //Rightmost comma location
- int tempI5 = 0; //Rightmost location of and
- int tempI6 = 0; //Current place in vector
- int tempI7 = 0; // Special line corrections made
- string ReadContent(const string& s1)
- {
- fstream tempTunnel90;
- string returnString;
- string tempGetString90;
- tempTunnel90.open(s1.c_str(), fstream::in);
- long int currentFileLine60 = 0;
- char tChar90[700];
- if(!(tempTunnel90.is_open()))
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION ReadContent: " << "\n";
- cout << "TRIED TO OPEN " << s1 << " BUT FAILED\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- return "blarg";
- }
- do
- {
- currentFileLine60++;
- tempTunnel90.getline(tChar90, 700);
- tempGetString90 = tChar90;
- returnString = returnString + tempGetString90 + "\n";
- }
- while (tempTunnel90.eof() != true);
- tempTunnel90.close();
- return returnString;
- }
- //USAGE:
- //NOTE: CASE SENSITIVE
- // CutOut(originString, leftmost string, rightmost string)
- // CutOut("<uiIndex>5</uiIndex>", "<uiIndex>","</uiIndex>")
- //
- //EXCEPTIONS:
- // IF CANNOT FIND SECOND TAG, WILL CUT ALL THE WAY TO END
- // OF THE STRING
- // IF CANNOT FIND FIRST TAG, WILL RETURN 'blarg'
- string CutOut(const string& s1, const string& s2, const string& s3)
- {
- long long int place1 = -1;
- long long int place2 = -1;
- string returnString="blarg";
- place1 = s1.find(s2);
- if(place1 <= -1)
- {
- return returnString;
- }
- place1 = place1 + s2.size();
- place1--;
- place2 = s1.find(s3, (place1 + 1));
- if(place2 <= -1)
- {
- place2 = s1.size() - 1;
- }
- returnString = s1.substr((place1+1),((place2-place1)-1));
- return returnString;
- }
- long long int CutOutInt(const string& s1, const string& s2, const string& s3)
- {
- long long int place1 = -1;
- long long int place2 = -1;
- long long int returnInt=-1;
- string returnString = "";
- place1 = s1.find(s2);
- if(place1 <= -1)
- {
- return returnInt;
- }
- place1 = place1 + s2.size();
- place1--;
- place2 = s1.find(s3, (place1 + 1));
- if(place2 <= -1)
- {
- place2 = s1.size() - 1;
- }
- returnString = s1.substr((place1+1),((place2-place1)-1));
- returnInt = atoi( returnString.c_str() );
- return returnInt;
- }
- long long int CutOutInt(const string& s1, const string& s2, const string& s3, unsigned long long int placeStart)
- {
- long long int place1 = -1;
- long long int place2 = -1;
- long long int returnInt=-1;
- string returnString = "";
- place1 = s1.find(s2,placeStart);
- if(place1 <= -1)
- {
- return returnInt;
- }
- place1 = place1 + s2.size();
- place1--;
- place2 = s1.find(s3, (place1 + 1));
- if(place2 <= -1)
- {
- place2 = s1.size() - 1;
- }
- returnString = s1.substr((place1+1),((place2-place1)-1));
- returnInt = atoi( returnString.c_str() );
- return returnInt;
- }
- string CutOut(const string& s1, const string& s2, const string& s3, unsigned long long int placeStart)
- {
- long long int place1 = -1;
- long long int place2 = -1;
- string returnString="blarg";
- place1 = s1.find(s2,placeStart);
- if(place1 <= -1)
- {
- // Special ERRORCHECK this function
- if(returnString == "blarg")
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION CutOut: " << "\n";
- cout << "BLARG returned to returnString: " << returnString << "\n";
- cout << "(MOST LIKELY RETURNED FROM CUTOUT\nBLARG MEANS FIRST TAG NOT FOUND)" << "\n";
- cout << "THIS MOST LIKELY MEANS THAT LESS\n";
- cout << "THAN FIVE <GEARKIT>s WERE FOUND\n";
- cout << "FATAL ERROR: CLOSE THIS PROGRAM\n";
- cout << "AND DO -not- CONTINUE\n";
- cout << "PLACESTART: " << placeStart << "\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- }
- return returnString;
- }
- place1 = place1 + s2.size();
- place1--;
- place2 = s1.find(s3, (place1 + 1));
- if(place2 <= -1)
- {
- place2 = s1.size() - 1;
- }
- returnString = s1.substr((place1+1),((place2-place1)-1));
- return returnString;
- }
- string CutLeft(const string& s1, const string& s2)
- {
- long long int place1 = 0;
- long long int place2 = -1;
- string returnString="blarg";
- place2 = s1.find(s2, (place1 + 1));
- if(place2 <= 0)
- {
- return returnString;
- }
- returnString = s1.substr(place1,place2);
- return returnString;
- }
- string CutLeft(const string& s1, const string& s2, unsigned long long int placeStart)
- {
- long long int place1 = 0;
- long long int place2 = -1;
- string returnString="blarg";
- place2 = s1.find(s2, placeStart);
- if(place2 <= 0)
- {
- return returnString;
- }
- returnString = s1.substr(place1,place2);
- return returnString;
- }
- string CutRight(const string& s1, const string& s2)
- {
- long long int place1 = -1;
- long long int place2 = ((s1.size()));
- string returnString="blarg";
- place1 = s1.find(s2);
- if(place1 <= -1)
- {
- return returnString;
- }
- place1 = place1 + s2.size();
- if(place1 >= (s1.size()-1))
- {
- return returnString;
- }
- place2 = place2 - place1;
- returnString = s1.substr(place1,place2);
- return returnString;
- }
- string CutRight(const string& s1, const string& s2, unsigned long long int placeStart)
- {
- long long int place1 = -1;
- long long int place2 = ((s1.size()));
- string returnString="blarg";
- place1 = s1.find(s2, placeStart);
- if(place1 <= -1)
- {
- return returnString;
- }
- place1 = place1 + s2.size();
- if(place1 >= (s1.size()-1))
- {
- return returnString;
- }
- place2 = place2 - place1;
- returnString = s1.substr(place1,place2);
- return returnString;
- }
- // USAGE:
- // ReadTag( <open tag> , <close tag> , <string> )
- // ReadTag("<value>","</value>",string1)
- string ReadTag (const string& s1, const string& s2, const string& s3)
- {
- string returnString = "blarg";
- long long unsigned int place1 = 0;
- long long unsigned int place2 = 0;
- long long unsigned int cutlength = 0;
- place1 = s3.find(s1, 0);
- place1 = place1 + (s1.size());
- place2 = s3.find(s2, place1);
- cutlength = place2 - place1;
- returnString = s3.substr(place1,cutlength);
- return returnString;
- }
- // USAGE:
- // ReadTag( <open tag> , <string> )
- // ReadTag("<value>", string1)
- string ReadTag (const string& s1, const string& s3)
- {
- string returnString = "blarg";
- string s2 = "</";
- long long unsigned int place1 = 0;
- long long unsigned int place2 = 0;
- long long unsigned int cutlength = 0;
- place1 = s3.find(s1,0);
- place1 = place1 + (s1.size());
- place2 = s3.find(s2, place1);
- cutlength = place2 - place1;
- returnString = s3.substr(place1,cutlength);
- return returnString;
- }
- string ReadTag (const string& s1, const string& s2, const string& s3, long long unsigned int placeStart)
- {
- string returnString = "blarg";
- long long unsigned int place1 = 0;
- long long unsigned int place2 = 0;
- long long unsigned int cutlength = 0;
- place1 = s3.find(s1, placeStart);
- place1 = place1 + (s1.size());
- place2 = s3.find(s2, place1);
- cutlength = place2 - place1;
- returnString = s3.substr(place1,cutlength);
- return returnString;
- }
- // USAGE:
- // ReadTag( <open tag> , <string> , <integer>)
- // ReadTag("<value>", string1, 829)
- string ReadTag (const string& s1, const string& s3, long long unsigned int placeStart)
- {
- string returnString = "blarg";
- string s2 = "</";
- long long unsigned int place1 = 0;
- long long unsigned int place2 = 0;
- long long unsigned int cutlength = 0;
- place1 = s3.find(s1, placeStart);
- place1 = place1 + (s1.size());
- place2 = s3.find(s2, place1);
- cutlength = place2 - place1;
- returnString = s3.substr(place1,cutlength);
- return returnString;
- }
- // USAGE:
- // ReadTag( <open tag> , <string> , <integer>)
- // ReadTag("<value>", string1, 829)
- int FindTag (const string& s1,const string& s3)
- {
- long long unsigned int place1 = 0;
- place1 = s3.find(s1, 0);
- // place1 = place1 + (s1.size());
- return place1;
- }
- int FindTagValue (const string& s1,const string& s3)
- {
- long long unsigned int place1 = 0;
- place1 = s3.find(s1, 0);
- place1 = place1 + (s1.size());
- return place1;
- }
- // USAGE:
- // FindTag ( <open tag> , <string> , <integertostart> )
- // FindTag ("<value>", string1, 829)
- int FindTag (const string& s1, const string& s3,long long unsigned int placeStart)
- {
- long long unsigned int place1 = 0;
- place1 = s3.find(s1, placeStart);
- // place1 = place1 + (s1.size());
- return place1;
- }
- int FindTagValue (const string& s1, const string& s3,long long unsigned int placeStart)
- {
- long long unsigned int place1 = 0;
- place1 = s3.find(s1, placeStart);
- place1 = place1 + (s1.size());
- return place1;
- }
- unsigned long long int ReturnFileNumber (const string& inputString)
- {
- long long int returnedNumber = -1;
- string parseStringT = "";
- long long int indexPos = -1;
- int throwAway2 = -1;
- string throwAway3 = "blarg";
- indexPos = inputString.find_last_of("1234567890");
- if(indexPos != -1)
- {
- do
- {
- parseStringT = inputString[indexPos] + parseStringT;
- indexPos--;
- throwAway2 = -1;
- throwAway3 = "blarg";
- if((indexPos < inputString.size()) && (indexPos >= 0))
- {
- throwAway3 = inputString[indexPos];
- throwAway2 = throwAway3.find_first_of("1234567890");
- }
- else
- {
- returnedNumber = atoi( parseStringT.c_str() );
- if(returnedNumber == -1)
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION ReturnFileNumber: " << inputString << "\n";
- cout << "TRIED TO PARSE " << parseStringT << " BUT DID NOT RETURN INTEGER\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- }
- break;
- }
- if(throwAway2 != -1)
- {
- continue;
- }
- else
- {
- returnedNumber = atoi( parseStringT.c_str() );
- if(returnedNumber == -1)
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION ReturnFileNumber: " << inputString << "\n";
- cout << "TRIED TO PARSE " << parseStringT << " BUT DID NOT RETURN INTEGER\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- }
- break;
- }
- }
- while(indexPos !=-1);
- }
- return returnedNumber;
- }
- bool compareNoCase( const string& s1, const string& s2 )
- {
- bool returnValue = false;
- if((s1.size()) == (s2.size()))
- {
- returnValue = strcasecmp( s1.c_str(), s2.c_str() ) <= 0;
- }
- else
- {
- returnValue = s1.size() < s2.size();
- }
- return returnValue;
- }
- bool compareNoCaseSameSizeCustom( const string& s1, const string& s2 )
- {
- bool returnValue = false;
- if((s1.size()) == (s2.size()))
- {
- returnValue = strcasecmp( s1.c_str(), s2.c_str() ) <= 0;
- }
- else
- {
- return false;
- }
- return returnValue;
- }
- void toUpper(string& str) {
- for(int x=0; x<str.length(); x++)
- str[x]=toupper(str[x]);
- }
- void toLower(basic_string<char>& s) {
- for (basic_string<char>::iterator p = s.begin();
- p != s.end(); ++p) {
- *p = tolower(*p);
- }
- }
- void toLower(basic_string<wchar_t>& s) {
- for (basic_string<wchar_t>::iterator p = s.begin();
- p != s.end(); ++p) {
- *p = towlower(*p);
- }
- }
- void listdir (const char *path)
- {
- // first off, we need to create a pointer to a directory
- DIR *pdir = NULL; // remember, it's good practice to initialise a pointer to NULL!
- pdir = opendir (path); // "." will refer to the current directory
- struct dirent *pent = NULL;
- if (pdir == NULL) // if pdir wasn't initialised correctly
- { // print an error message and exit the program
- printf ("\nERROR! pdir could not be initialised correctly");
- return; // exit the function
- } // end if
- while (pent = readdir (pdir)) // while there is still something in the directory to list
- {
- if (pent == NULL) // if pent has not been initialised correctly
- { // print an error message, and exit the program
- printf ("\nERROR! pent could not be initialised correctly");
- return; // exit the function
- }
- // otherwise, it was initialised correctly. let's print it on the console:
- printf ("%s\n", pent->d_name);
- }
- // finally, let's close the directory
- closedir (pdir);
- }
- // Probes directory path.
- // If no directory, creates it. All of it.
- // , ofstream& osInput
- bool forceDir(basic_string<char>& thePath)
- {
- int cursor = 0;
- string returnedString = "blarg";
- bool returnBool = false;
- vector<string> tryStrings;
- DIR *pdir = NULL;
- //Check if already exists
- pdir = NULL;
- pdir = opendir (thePath.c_str());
- if(pdir != NULL)
- {
- cout << "DIRECTORY " << thePath << " ALREADY EXISTS.";
- return true;
- }
- else
- {
- pdir = NULL;
- }
- if(thePath[0] == '\\')
- {
- cursor++;
- }
- do
- {
- returnedString = CutLeft(thePath,"\\",cursor);
- if(returnedString != "blarg")
- {
- tryStrings.push_back (returnedString);
- cursor = thePath.find("\\", cursor);
- cursor++;
- }
- else
- {
- tryStrings.push_back (thePath);
- break;
- }
- }
- while(cursor < thePath.size());
- if(tryStrings.size() == 0)
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION forceDir: " << "\n";
- cout << "PARSED VECTOR OF FILE PATHS WAS 0\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- return false;
- }
- cursor = 0;
- string path = "blarg";
- do
- {
- pdir = NULL;
- path = tryStrings[cursor];
- pdir = opendir (path.c_str());
- if(pdir != NULL)
- {
- cout << "OPENED " << path << " SUCCESSFULLY\n";
- // system("PAUSE");
- cursor++;
- closedir (pdir);
- }
- else
- {
- int tempThrowaway3 = mkdir(path.c_str());
- if(tempThrowaway3 == -1)
- {
- returnBool = false;
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION forceDir: " << "\n";
- cout << "COULD NOT FORCE-CREATE DIRECTORY " << path << "\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- return false;
- }
- else
- {
- cout << "CREATED " << path << " SUCCESSFULLY\n";
- // system("PAUSE");
- cursor++;
- }
- }
- }
- while(cursor < (tryStrings.size()));
- pdir = opendir (thePath.c_str());
- if(pdir != NULL)
- {
- returnBool = true;
- closedir (pdir);
- }
- else
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION forceDir: " << "\n";
- cout << "FINAL DIRECTORY OPEN CHECK FAILED " << thePath << "\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- returnBool = false;
- }
- /*
- if (!mkdir (".\\dream.in.code"))
- {
- printf ("mkdir() unsuccessful. Terminating...");
- exit (3); // exit after a 3 second pause
- } // otherwise, it was created, so we can continue
- std::cout << "dream.in.code folder created successfully!"
- << "Currently viewing:\n%s\n" << getcwd(NULL,0);
- listdir (".");
- std::cout << "\nMoving into our newly created directory";
- chdir (".\\dream.in.code");
- std::cout << "\nCurrently viewing:\n%s\n" << getcwd(NULL,0);
- listdir (".");
- chdir ("..\\"); // move back one
- rmdir (".\dream.in.code");
- listdir (".");
- std::cin.get (); // pause for input
- return EXIT_SUCCESS; // program was executed successfully
- */
- return returnBool;
- }
- // USAGE:
- // ReplaceTag ( left tag, right tag, original value, new value , working string)
- // ReplaceTag ("<myTag>","</myTag>","10","15", s1)
- // EXCEPTIONS:
- // Use "*" for original value to denote that all values should be replaced between
- // these tags (you could just use RegX for that anyway)
- string ReplaceTag ( const string& s1,const string& s2,const string& s3,const string& s4,const string& s5 )
- {
- string returnString = "blarg";
- string currValue = "blarg";
- string leftString = "blarg";
- string rightString = "blarg";
- long long unsigned int place1 = 0;
- long long unsigned int place2 = 0;
- long long unsigned int place3 = 0;
- place1 = FindTagValue(s1,s5);
- if(place1==0)
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION replaceTag: " << "\n";
- cout << "TAG FIND FAILURE " << s1 << " ; " << s2 << "\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- }
- place2 = FindTag(s1,s5);
- if(place2==0)
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION replaceTag: " << "\n";
- cout << "TAG2 FIND FAILURE " << s1 << " ; " << s2 << " ; " << place1 << "\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- }
- currValue = ReadTag( s1, s5);
- if((compareNoCaseSameSizeCustom(currValue, s3)) || (s3 == "*"))
- {
- leftString = s5.substr(0 , place1);
- rightString = s5.substr( ((place1+currValue.size())) ,(s5.size() - (place1 + (currValue.size()-1))));
- returnString = leftString + s4;
- returnString = returnString + rightString;
- }
- currValue = ReadTag( s1, returnString);
- cout << "-----------********----------\n";
- cout << "INFORMATION: " << "\n";
- cout << "currValue: " << returnString.size() << " ; " << s5.size() << " ; " << s5 << "\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- if(currValue != s4)
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION replaceTag: " << "\n";
- cout << "FINAL VALUE MISMATCH incorrect: " << currValue << " ; Correct: " << s4 << "\n";
- cout << " (PROB DUE TO TAG READ ERROR)" << "\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- }
- return returnString;
- }
- string ReplaceTag ( const string& s1,const string& s2,const string& s3,const string& s4,const string& s5,unsigned long long int placeStart )
- {
- string returnString = "blarg";
- string currValue = "blarg";
- string leftString = "blarg";
- string rightString = "blarg";
- long long unsigned int place1 = 0;
- long long unsigned int place2 = 0;
- long long unsigned int place3 = 0;
- place1 = FindTagValue(s1,s5,placeStart);
- if(place1==0)
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION replaceTag: " << "\n";
- cout << "TAG FIND FAILURE " << s1 << " ; " << s2 << "\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- }
- place2 = FindTag(s1,s5,placeStart);
- if(place2==0)
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION replaceTag: " << "\n";
- cout << "TAG2 FIND FAILURE " << s1 << " ; " << s2 << " ; " << place1 << "\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- }
- currValue = ReadTag( s1, s2, s5, placeStart);
- if((compareNoCaseSameSizeCustom(currValue, s3)) || (s3 == "*"))
- {
- leftString = s5.substr(0 , place1);
- rightString = s5.substr( ((place1+currValue.size())) ,(s5.size() - (place1 + (currValue.size()-1))));
- returnString = leftString + s4;
- returnString = returnString + rightString;
- }
- currValue = ReadTag( s1, s2, returnString, place2);
- // cout << "-----------********----------\n";
- // cout << "INFORMATION: " << "\n";
- // cout << "returnString/InputString: " << returnString.size() << " ; " << s5.size() << " ; " << "\n";
- // cout << "-----------********----------\n\n";
- // system("PAUSE");
- if(currValue != s4)
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION replaceTag: " << "\n";
- cout << "FINAL VALUE MISMATCH incorrect: " << currValue << " ; Correct: " << s4 << "\n";
- cout << " (PROB DUE TO READTAG ERROR)" << "\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- }
- return returnString;
- }
- //USAGE:
- // CutWhole(<source string>, <open tag>, <close tag>, <integer to start>)
- // CutWhole(mySource1, "<hello>", "</hello>", 0)
- //
- //
- // RETURNS: This will add <open tag> and <close tag> to beginning and end of
- // whatever content are in the middle of them. Essentially returning a
- // Cutout but WITH the tags, too.
- string CutWhole(const string& s1, const string& s2, const string& s3, unsigned long long int placeStart)
- {
- string tempHolding8080 = "blarg";
- string returnString = "";
- tempHolding8080 = CutOut(s1,s2,s3,placeStart);
- //ERRORCHECK
- if(tempHolding8080 == "blarg")
- {
- cout << "-----------********----------\n";
- cout << "ERROR FUNCTION CutWhole: " << "\n";
- cout << "BLARG returned to tempHolding8080: " << tempHolding8080 << "\n";
- cout << "(MOST LIKELY RETURNED FROM CUTOUT\nBLARG MEANS FIRST TAG NOT FOUND)" << "\n";
- cout << "THIS MOST LIKELY MEANS THAT LESS\n";
- cout << "THAN FIVE <GEARKIT>s WERE FOUND\n";
- cout << "FATAL ERROR: CLOSE THIS PROGRAM\n";
- cout << "AND DO -not- CONTINUE\n";
- cout << "-----------********----------\n\n";
- system("PAUSE");
- }
- returnString = returnString + s2;
- returnString = returnString + tempHolding8080;
- returnString = returnString + s3;
- return returnString;
- }
- int main()
- {
- cout << "============***********************===========\n";
- cout << "............STANDARD EQUIPMENT PROGRAM........\n";
- cout << "============***********************===========\n\n";
- srand((unsigned)time(0));
- int throwAway0 = rand() % 9 + 1;
- if(throwAway0 == 1)
- {
- cout << "\"THE ONLY GOOD GEARKIT IS A DEAD GEARKIT\"\n\n\n";
- }
- if(throwAway0 == 2)
- {
- cout << "\"WHY DIDNT BIFF GET AN UMBRELLA\"\n\n\n";
- }
- if(throwAway0 == 3)
- {
- cout << "\"FLUGENTE GAVE ME CODER'S RASH\"\n\n\n";
- }
- if(throwAway0 == 4)
- {
- cout << "\"THEY SAID DEPRI WAS A LADY\"\n\n\n";
- }
- if(throwAway0 == 5)
- {
- cout << "\"IT'S TOO MUCH WORK\" - JA2 Community\n\n\n";
- }
- if(throwAway0 == 6)
- {
- cout << "\"CANADIAN CODE IS BEST CODE\"\n\n\n";
- }
- if(throwAway0 == 7)
- {
- cout << "\"FLUGENTE STOLE ALL OUR BASE\"\n\n\n";
- }
- if(throwAway0 == 8)
- {
- cout << "\"CVB is on a killstreak of 0!\"\n\n\n";
- }
- if(throwAway0 == 9)
- {
- cout << "\"silversurfer HAS FIXED THE TRUNK. Again.\"\n\n\n";
- }
- // ADD PRE-FLIGHT CHECKLIST FOR MORONS WHO DONT READ THE INSTRUCTIONS.txt
- cout << "-----------------------------------------------\n";
- cout << "BEGINNING ANALYSIS OF [\\ReplaceWith.txt]\n";
- cout << "-----------------------------------------------\n\n\n";
- // DEFINE GEARKIT REPLACEMENTS
- // READ FROM ReplaceWith.txt
- string replace1 = "blarg";
- string replace2 = "blarg";
- string replace3 = "blarg";
- string replace4 = "blarg";
- string replace5 = "blarg";
- tempS1 = ""; // Holding for ReplaceWith.txt
- tempS2 = ""; // Temp for CutOut splice
- tempS1 = ReadContent("ReplaceWith.txt");
- tempI1 = 0;
- tempI1 = FindTag("<GEARKIT>",tempS1,0);
- replace1 = CutOut(tempS1,"<GEARKIT>","</GEARKIT>",tempI1);
- tempI1++;
- tempI1 = FindTag("<GEARKIT>",tempS1,tempI1);
- replace2 = CutOut(tempS1,"<GEARKIT>","</GEARKIT>",tempI1);
- tempI1++;
- tempI1 = FindTag("<GEARKIT>",tempS1,tempI1);
- replace3 = CutOut(tempS1,"<GEARKIT>","</GEARKIT>",tempI1);
- tempI1++;
- tempI1 = FindTag("<GEARKIT>",tempS1,tempI1);
- replace4 = CutOut(tempS1,"<GEARKIT>","</GEARKIT>",tempI1);
- tempI1++;
- tempI1 = FindTag("<GEARKIT>",tempS1,tempI1);
- replace5 = CutOut(tempS1,"<GEARKIT>","</GEARKIT>",tempI1);
- cout << "-----------------------------------------------\n";
- cout << "READING OF [\\ReplaceWith.txt] COMPLETE\n";
- cout << "-----------------------------------------------\n\n\n";
- cout << "-----------------------------------------------\n";
- cout << "BEGINNING READ OF [\\Input.txt] \n";
- cout << "( No it's not frozen, please wait... )\n";
- cout << "-----------------------------------------------\n\n\n";
- string inputFileString = "";
- inputFileString = ReadContent("Input.txt");
- tempI1 = 0; //PRIMARY CURSOR
- tempI2 = inputFileString.size(); //End cursor
- tempI3 = 1; // Count to 5 interator
- tempS1 = "";
- tempS2 = "";
- tempS3 = ""; //DEBUG PURPOSES ONLY
- cout << "-----------------------------------------------\n";
- cout << "READING OF [\\Input.txt] COMPLETE\n";
- cout << "-----------------------------------------------\n\n\n";
- cout << "-----------------------------------------------\n";
- cout << "BEGIN PRIMARY REPLACE LOOP\n";
- cout << "-----------------------------------------------\n\n\n";
- do
- {
- tempI1 = inputFileString.find("<GEARKIT>", tempI1);
- if(tempI1 == -1)
- {
- cout << "-----------********----------\n";
- cout << "PRIMARY REPLACE LOOP COMPLETE\n";
- cout << "-----------********----------\n\n\n";
- break;
- }
- // tempS3 = CutOut(inputFileString, "<GEARKIT>", "</GEARKIT>",tempI1);
- // cout << "-----------********----------\n";
- // cout << "INFORMATION: " << "\n";
- // cout << "Current replace target: \n" << tempS3.size() << "\n";
- // cout << "-----------********----------\n\n";
- // system("PAUSE");
- if(tempI3==1)
- {
- inputFileString = ReplaceTag( "<GEARKIT>","</GEARKIT>","*",replace1,inputFileString,tempI1 );
- tempI3++;
- tempI1++;
- continue;
- }
- if(tempI3==2)
- {
- inputFileString = ReplaceTag( "<GEARKIT>","</GEARKIT>","*",replace2,inputFileString,tempI1 );
- tempI3++;
- tempI1++;
- continue;
- }
- if(tempI3==3)
- {
- inputFileString = ReplaceTag( "<GEARKIT>","</GEARKIT>","*",replace3,inputFileString,tempI1 );
- tempI3++;
- tempI1++;
- continue;
- }
- if(tempI3==4)
- {
- inputFileString = ReplaceTag( "<GEARKIT>","</GEARKIT>","*",replace4,inputFileString,tempI1 );
- tempI3++;
- tempI1++;
- continue;
- }
- if(tempI3==5)
- {
- inputFileString = ReplaceTag( "<GEARKIT>","</GEARKIT>","*",replace5,inputFileString,tempI1 );
- tempI3 = 1;
- tempI1++;
- continue;
- }
- }
- while(true);
- cout << "----------------********---------------\n";
- cout << "WRITING TO OUTPUT FILE MercStartingGear.xml\n";
- cout << "----------------********---------------\n\n";
- ofstream myfile2;
- myfile2.open ("MercStartingGear.xml", ios::out);
- myfile2 << inputFileString;
- myfile2.close();
- // TESTING //
- // cout << replace5 <<"\n\n";
- // system("PAUSE");
- // return 0;
- // TESTING //
- cout << "--------------\n";
- cout << "END OF PROGRAM\n";
- cout << "--------------\n\n";
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement