Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <fstream>
- #include <string>
- #include <sstream>
- using namespace std;
- class scht {
- private:
- static vector <string[]> friends;
- static string privatekey;
- static string publickey;
- public:
- static string getFriend(int);
- static void addFriend(string, string);
- static void loadFriend(string, string);
- void write(string, string, int);
- scht();
- ~scht();
- string ciper(string);
- };
- string scht::getFriend(int index) { return (string[])friends.at(index); }
- void scht::addFriend(string name, string publickey) {}
- string scht::ciper(string toCiper) {
- return toCiper; // do later more
- }
- void scht::loadFriend(string name, string pubickey) {
- friends.push_back({name, publickey});
- }
- void scht::write(string text, string title, int id) {
- string contact[2] = getFriend(id);
- string cipertext = ciper(text);
- string cipertitle = ciper(title);
- // BROADCAST
- }
- scht::scht() {
- ifstream friendsFile;
- string line;
- string arr[2];
- friendsFile.open("friends.csv", ios::in);
- if(friendsFile.is_open()) {
- while(getline(friendsFile, line)) {
- try {
- for (int i=0; i<line.length(); i++)
- {
- if (line[i] == ';')
- line[i] = ' ';
- }
- vector<string> array;
- stringstream ss(line);
- string temp;
- while (ss >> temp)
- array.push_back(temp);
- if(array.size() != 2)
- throw(1);
- loadFriend(array.at(0), array.at(1));
- } catch(...) {
- throw("[ERROR] to much arguments in one line. please check the 'friends.csv' file!");
- }
- }
- }
- friendsFile.close();
- }
- scht::~scht() { cout << endl << "bye bye" << endl; }
- int main() {
- scht prog;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement