NCBI C++ ToolKit
tab_table_reader.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef STRUCT_CMT_READER_HPP
2 #define STRUCT_CMT_READER_HPP
3 
4 #include <corelib/ncbistl.hpp>
5 
7 
8 // forward declarations
9 namespace objects
10 {
11  class ILineErrorListener;
12 };
13 
14 class CSerialObject;
15 class ILineReader;
16 
17 /*
18  Usage examples
19 */
20 
22 {
23  string m_src;
24  int m_row;
25  int m_col;
26  bool m_warning;
27  string m_msg;
28  string m_colname;
29 };
30 
32 {
33 public:
34  enum e_Flags
35  {
45  };
46 
47  // If you need messages and error to be logged
48  // supply an optional ILineErrorListener instance
50  m_flags(flags)
51  {
52  }
53 
54  // TODO: replace with options flags instead of parameters
55  void ValidateInput(ILineReader& reader,
56  const string& default_columns, const string& required,
57  const string& ignored, const string& unique,
58  const string& discouraged,
59  const vector<string>& require_one);
60 
61  void GenerateOutput(CNcbiOstream* out_stream, bool no_headers);
62  static void RegisterAliases(CNcbiIstream* in_stream);
63 
64 private:
65  bool _Validate(int col_number, const CTempString& value);
66 
67  void _OperateRows(ILineReader& reader);
68  bool _ProcessHeader(ILineReader& reader, const CTempString& default_cols);
69  bool _CheckHeader(const string& discouraged, const vector<string>& require_one);
70 
71  bool _MakeColumns(const string& message,
72  const CTempString& columns, vector<bool>& col_defs);
73 
74  void _ReportError(int col_number, const CTempString& error, const CTempString& colname, bool warning = false);
75  void _ReportWarning(int col_number, const CTempString& error, const CTempString& colname);
76  void _ReportTab(CNcbiOstream* out_stream);
77  void _ReportXML(CNcbiOstream* out_stream, bool no_headers);
78 
79 
82  vector<string> m_col_defs;
83  vector<bool> m_required_cols;
84  vector<bool> m_ignored_cols;
85  vector<bool> m_unique_cols;
86  vector< set<string> > m_require_one_cols;
87 
88  vector< map<string, int> > m_unique_values;
89 
90  list<CTabDelimitedValidatorMessage> m_errors;
92 };
93 
95 
96 
97 #endif
Base class for all serializable objects.
Definition: serialbase.hpp:150
static void RegisterAliases(CNcbiIstream *in_stream)
vector< bool > m_required_cols
void _OperateRows(ILineReader &reader)
void _ReportXML(CNcbiOstream *out_stream, bool no_headers)
vector< bool > m_unique_cols
bool _MakeColumns(const string &message, const CTempString &columns, vector< bool > &col_defs)
vector< bool > m_ignored_cols
CTabDelimitedValidator(e_Flags flags=e_tab_tab_delim)
void _ReportError(int col_number, const CTempString &error, const CTempString &colname, bool warning=false)
list< CTabDelimitedValidatorMessage > m_errors
void ValidateInput(ILineReader &reader, const string &default_columns, const string &required, const string &ignored, const string &unique, const string &discouraged, const vector< string > &require_one)
bool _CheckHeader(const string &discouraged, const vector< string > &require_one)
void _ReportTab(CNcbiOstream *out_stream)
void _ReportWarning(int col_number, const CTempString &error, const CTempString &colname)
void GenerateOutput(CNcbiOstream *out_stream, bool no_headers)
vector< map< string, int > > m_unique_values
bool _Validate(int col_number, const CTempString &value)
vector< set< string > > m_require_one_cols
bool _ProcessHeader(ILineReader &reader, const CTempString &default_cols)
vector< string > m_col_defs
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
Abstract base class for lightweight line-by-line reading.
Definition: line_reader.hpp:54
static uch flags
static const column_t columns[]
Definition: utf8_2.c:22
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
The NCBI C++/STL use hints.
Modified on Fri Sep 20 14:57:01 2024 by modify_doxy.py rev. 669887