#include <csvimport.h>

Classes | |
| struct | LogEntry |
Public Member Functions | |
| CSVImport (std::string src, std::string dst, char sep, bool verb=true) throw (std::runtime_error) | |
| std::list< LogEntry > | getLog () const |
| Return the log entries. | |
| bool | getVerbose () const |
| Get the verbosity. | |
| bool | hadErrors () const |
| Return whether or not errors occurred. | |
| void | import (const char *pw) throw (std::exception) |
| Do the import. | |
| unsigned int | numErrors () const |
| Return the number of errors occurred. | |
| void | printLog () const |
| Print the log to stdout. | |
| void | setVerbose (bool v) |
| Set the verbosity. | |
| ~CSVImport () | |
Private Types | |
| enum | { NUM_SEPARATORS = 4 } |
Private Member Functions | |
| void | cleanupValue (std::string &str) |
| Cleanup the field values. | |
| CSVImport (const CSVImport &) | |
| void | logError (unsigned long lno, const std::string &errmsg) |
| Log the given error. | |
| const CSVImport & | operator= (const CSVImport &) |
Private Attributes | |
| std::string | dstfile |
| bool | had_errors |
| std::list< LogEntry > | logs |
| unsigned int | num_errors |
| char | separator |
| std::string | srcfile |
| bool | verbose |
The class taking care of converting a csv file.
Definition at line 46 of file csvimport.h.
anonymous enum [private] |
Definition at line 74 of file csvimport.h.
| CSVImport::CSVImport | ( | const CSVImport & | ) | [inline, private] |
Object copying not allowed.
Definition at line 72 of file csvimport.h.
| CSVImport::CSVImport | ( | std::string | src, | |
| std::string | dst, | |||
| char | sep, | |||
| bool | verb = true | |||
| ) | throw (std::runtime_error) |
The constructor tests whether the given source file exists and can be read. May return a std::runtime_error if this is not the case
| src | the file path of the source file. | |
| dst | the file path of the destination file. | |
| sep | the separator used for fields. | |
| verb | enable/disable verbosity. Default true. |
Definition at line 121 of file csvimport.cc.
| CSVImport::~CSVImport | ( | ) | [inline] |
Definition at line 119 of file csvimport.h.
| void CSVImport::cleanupValue | ( | std::string & | str | ) | [private] |
Removes the double quotes at the beginning and any escaped double quotes.
| str | the string to be cleaned up. |
str passed will be modified. Definition at line 67 of file csvimport.cc.
| std::list<LogEntry> CSVImport::getLog | ( | ) | const [inline] |
Definition at line 139 of file csvimport.h.
References logs.
| bool CSVImport::getVerbose | ( | ) | const [inline] |
Definition at line 127 of file csvimport.h.
References verbose.
| bool CSVImport::hadErrors | ( | ) | const [inline] |
Definition at line 131 of file csvimport.h.
References had_errors.
Referenced by main().

| void CSVImport::import | ( | const char * | pw | ) | throw (std::exception) |
Does the import.
| pw | the password set on the destination file. |
Definition at line 138 of file csvimport.cc.
References clear(), YAPET::PasswordRecord::comment, YAPET::COMMENT_SIZE, YAPET::PasswordRecord::host, YAPET::HOST_SIZE, YAPET::PasswordRecord::name, YAPET::NAME_SIZE, YAPET::PasswordRecord::password, YAPET::PASSWORD_SIZE, YAPET::File::save(), YAPET::PasswordRecord::username, and YAPET::USERNAME_SIZE.
Referenced by main().


| void CSVImport::logError | ( | unsigned long | lno, | |
| const std::string & | errmsg | |||
| ) | [private] |
Logs the given error.
| lno | the line number the error occurred. | |
| errmsg | the error message. |
Definition at line 94 of file csvimport.cc.
References had_errors, CSVImport::LogEntry::lineno, logs, CSVImport::LogEntry::message, num_errors, and verbose.
| unsigned int CSVImport::numErrors | ( | ) | const [inline] |
Definition at line 135 of file csvimport.h.
References num_errors.
Referenced by main().

Object assignment not allowed.
Definition at line 66 of file csvimport.h.
| void CSVImport::printLog | ( | ) | const |
Prints the log entries to stdout.
Definition at line 260 of file csvimport.cc.
References logs.
Referenced by main().

| void CSVImport::setVerbose | ( | bool | v | ) | [inline] |
Definition at line 123 of file csvimport.h.
References verbose.
std::string CSVImport::dstfile [private] |
The file path of the destination (pet) file.
Definition at line 88 of file csvimport.h.
bool CSVImport::had_errors [private] |
Indicates the occurrence of errors.
Definition at line 101 of file csvimport.h.
Referenced by hadErrors(), and logError().
std::list<LogEntry> CSVImport::logs [private] |
Holds the log entries in case of errors.
Definition at line 110 of file csvimport.h.
Referenced by getLog(), logError(), and printLog().
unsigned int CSVImport::num_errors [private] |
The number of errors occurred.
Definition at line 105 of file csvimport.h.
Referenced by logError(), and numErrors().
char CSVImport::separator [private] |
The separator character.
Definition at line 92 of file csvimport.h.
std::string CSVImport::srcfile [private] |
The file path of the source (csv) file.
Definition at line 84 of file csvimport.h.
bool CSVImport::verbose [private] |
Verbosity enabled/disabled.
Definition at line 97 of file csvimport.h.
Referenced by getVerbose(), logError(), and setVerbose().
1.7.1