Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <iostream>
- #include <string>
- #include <vector>
- #include <fstream>
- #include <sstream>
- #include <stdlib.h>
- using namespace std;
- /*
- vout(vector<string/int/char>);
- // just std::cout << string/int/char << endl;
- test();
- // this just std outputs "this is a test"
- getFileInput("locationoftextFile");
- // this returns vector of strings of text file
- String2Int(string);
- // converts string to int
- Int2String(int);
- //converts int to string
- cStringSplit(string input, string delimiter);
- // returns vector of strings separated by the delimiter
- */
- vector<string> returnMapKeyString(map<string, string> userInput) {
- vector<string> returnObject;
- for (auto element : userInput) {
- returnObject.push_back(element.first);
- }
- return returnObject;
- }
- vector<string> returnMapValueString(map<string, string> userInput) {
- vector<string> returnObject;
- for (auto element : userInput) {
- returnObject.push_back(element.second);
- }
- return returnObject;
- }
- vector<int> returnMapKeyInt(map<int, int> userInput) {
- vector<int> returnObject;
- for (auto element : userInput) {
- returnObject.push_back(element.first);
- }
- return returnObject;
- }
- vector<int> returnMapValueInt(map<int, int> userInput) {
- vector<int> returnObject;
- for (auto element : userInput) {
- returnObject.push_back(element.second);
- }
- return returnObject;
- }
- void readStringMap(map<string, string> userInput) {
- cout << endl;
- for (auto element : userInput) {
- cout << element.first << " <= " << element.second << endl;
- }
- cout << endl;
- }
- void readIntMap(map<int, int> userInput) {
- cout << endl;
- for (auto element : userInput) {
- cout << element.first << " <= " << element.second << endl;
- }
- cout << endl;
- }
- vector <int> String2Int(vector <string> tempVector) {
- stringstream tempSS;
- vector <int> tempIntVector;
- int tempInt;
- for (int i = 0; i < tempVector.size(); i++) {
- tempSS << tempVector.at(i);
- tempSS >> tempInt;
- tempIntVector.push_back(tempInt);
- }
- return tempIntVector;
- }
- int String2Int(string userInput) {
- stringstream tempSS;
- int tempInt;
- tempSS << userInput;
- tempSS >> tempInt;
- return tempInt;
- }
- vector <string> cStringSplit(string input, string delimeter) {
- int delimSize = delimeter.length();
- int inputSize = input.length();
- string buffer;
- vector <string> v;
- for (int i = 0; i < inputSize; i++) {
- if (input.substr(i, delimSize) != delimeter) {
- buffer += input[i];
- }
- else {
- v.push_back(buffer);
- buffer = "";
- i = i + delimSize - 1;
- }
- }
- v.push_back(buffer);
- buffer = "";
- return v;
- }
- vector<string> getInputFile(string location) {
- // good example getFile("C:\\temp\\New Text Document.txt");
- ifstream fileInput;
- vector<string> tempVector;
- string tempString;
- fileInput.open(location);
- while (!fileInput.eof())
- {
- getline(fileInput, tempString);
- tempVector.push_back(tempString);
- tempString = " ";
- }
- return tempVector;
- }
- void vout(vector<string> temp) { for (string c : temp) { cout << c << endl; } }
- void vout(vector<int> temp) { for (int c : temp) { cout << c << endl; } }
- void vout(vector<bool> temp) { for (bool c : temp) { cout << c << endl; } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement