OpenM++ runtime library (libopenm)
modelSqlWriter.h
Go to the documentation of this file.
1
5// Copyright (c) 2013-2015 OpenM++
6// This code is licensed under the MIT license (see LICENSE.txt for details)
7
8#ifndef MODEL_SQL_WRITER_H
9#define MODEL_SQL_WRITER_H
10
11#include <fstream>
12#include <streambuf>
13
14using namespace std;
15
16namespace openm
17{
20 {
21 public:
24
26 ofstream outFs;
27
29 ModelSqlWriter(const string & i_filePath);
30
32 ~ModelSqlWriter() noexcept;
33
35 void throwOnFail(void) const;
36
38 void write(const char * i_str);
39
41 void writeLine(const string & i_line);
42
44 void writeQuoted(const string & i_str, bool i_isAppendComma = false);
45
47 void writeTrimQuoted(const string & i_str, bool i_isAppendComma = false);
48
49 private:
50 locale defaultLoc; // default locale for char classification
51
53 void writeQuoted(string::const_iterator i_begin, string::const_iterator i_end);
54 };
55}
56
57#endif // MODEL_SQL_WRITER_H
openM++ namespace
Definition: log.h:32
wrapper around file stream to write into sql script file.
Definition: modelSqlWriter.h:20
string outFilePath
sql script file path
Definition: modelSqlWriter.h:23
ofstream outFs
sql scrpit output stream
Definition: modelSqlWriter.h:26
~ModelSqlWriter() noexcept
close sql script file
Definition: modelSqlWriter.cpp:30
void writeQuoted(const string &i_str, bool i_isAppendComma=false)
write string value sql-quoted: O'Brien -> 'O''Brien'
Definition: modelSqlWriter.cpp:58
void writeTrimQuoted(const string &i_str, bool i_isAppendComma=false)
write string value space trimed and sql-quoted
Definition: modelSqlWriter.cpp:85
void throwOnFail(void) const
throw exception on output stream fail
Definition: modelSqlWriter.cpp:36
void writeLine(const string &i_line)
write line into sql script file
Definition: modelSqlWriter.cpp:51
ModelSqlWriter(const string &i_filePath)
create new sql script file
Definition: modelSqlWriter.cpp:12
void write(const char *i_str)
write string into sql script file
Definition: modelSqlWriter.cpp:42