68 vector<string> str_arr;
81 if (
l !=
"#BKBTA-1") {
85 LOG_POST(
Warning <<
"BioTree attributes format: header signature '#BKBTA-1' is missing ");
96 if (ls.empty() || ls[0] !=
'#') {
98 "BioTree attributes format: line with column names expected: #name1 name2 name3... ",
103 if (str_arr.size() == 0) {
105 "BioTree attributes format: column name list is missing ",
109 ITERATE(vector<string>, it, str_arr) {
110 const string& attr_name = *it;
119 vector<string> row_values;
125 bool at_eof = line_reader.
AtEOF();
126 for (++line_reader;!at_eof; ++line_reader) {
127 at_eof = line_reader.
AtEOF();
129 if (ls.empty() || (ls[0] ==
'#')) {
132 row_values.resize(0);
134 if (row_values.size() == 0) {
141 for (
size_t i = 0;
i < row_values.size(); ++
i) {
142 if (
i >= attr_table.
Cols()) {
146 string& s = row_values[
i];
159 string& tcell = attr_table.
GetCell(
row, (
unsigned)
i);
173 if (s.empty())
return;
177 if (s.empty())
return;
179 if (s[s.length()-1] ==
'"') {
180 s.erase(s.length()-1, 1);
181 if (s.empty())
return;
190 "Input stream no longer valid ",
Template class to create a table with custom row-column access.
void AddColumn(const TColumn &col)
Add column to the table, column recieves name "col".
const TValueType & GetCell(unsigned int row_idx, unsigned int col_idx) const
Access table element by index.
void AddRow(const TRow &row)
Add row to the table, column recieves name "row".
unsigned int Cols() const
Number of column.
Simple implementation of ILineReader for i(o)streams.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Abstract base class for lightweight line-by-line reading.
The NCBI C++ standard methods for dealing with std::string.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Warning(CExceptionArgs_Base &args)
#define NCBI_THROW2(exception_class, err_code, message, extra)
Throw exception with extra parameter.
void Read(CNcbiIstream &is, TAttrTable &attr_table)
Read attributes stream into the table.
void TableValueDecode(string &s)
void CheckLineReader(ILineReader &ilr)
Uint8 GetLineNumber(void) const
Returns the current line number (counting from 1, not 0).
bool AtEOF(void) const
Indicates (negatively) whether there is any more input.
virtual Uint8 GetLineNumber(void) const =0
Returns the current line number (counting from 1, not 0).
virtual bool AtEOF(void) const =0
Indicates (negatively) whether there is any more input.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
Lightweight interface for getting lines of data with minimal memory copying.
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
#define row(bind, expected)