Created
August 21, 2008 06:00
-
-
Save jeffhung/6512 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool config_db::update_from_csv(const char* csv_file) | |
{ | |
try { | |
vector< vector<string> > data_table; | |
ifstream ifs(csv_file); | |
while (ifs) { | |
string line; | |
getline(ifs, line); | |
vector<string> tokens; | |
// splits line string delimited by ",", and save to tokens. | |
boost::split(tokens, line, is_any_of(",")); | |
// push row | |
data_table.push_back(vector<string>()); | |
data_table.back().swap(tokens); | |
} | |
// above may throw | |
this->data_table_.swap(data_table); // nothrow | |
return true; | |
} | |
catch (...) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment