File Import

- Added format identifier code for task 1.4.3, task 1.5.0, todo.sh
  2.0 and CSV.
- Implemented import for type text.
- Implemented util.cpp:slurp function.
- Gathered sample input files for import testing, and later, unit
  tests.
This commit is contained in:
Paul Beckingham 2009-03-26 00:41:15 -04:00
parent db7b2dd9fe
commit 99dc72f26f
8 changed files with 239 additions and 24 deletions

View file

@ -25,6 +25,7 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <sys/types.h>
@ -404,3 +405,28 @@ int flock (int fd, int operation)
#endif
////////////////////////////////////////////////////////////////////////////////
bool slurp (
const std::string& file,
std::vector <std::string>& contents,
bool trimLines /* = false */)
{
contents.clear ();
std::ifstream in (file.c_str ());
if (in.good ())
{
std::string line;
while (getline (in, line))
{
if (trimLines) line = trim (line);
contents.push_back (line);
}
in.close ();
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////