;
91 return "eEmptyDataSource";
93 return "eNoTrailingEOL";
95 return "eEmptyFieldName";
99 return "eEmptyFieldValue";
101 return "eValidateConversion";
150streamsize bytes_read = 0;
151streamsize total_read = 0;
154bytes_read = is.gcount();
155total_read += bytes_read;
175total_read !=
static_cast<ssize_t>(
data->size());
176 if(!
data->empty() &&
data->back() ==
'\r')
182vector<CTempString>& tokens)
184 if(raw_line.
empty())
186eEmptyLine,
"Empty lines are not allowed");
197 for(
const auto& name :
m_Tokens) {
201 "Empty field values are not allowed");
206eNumberOfFieldsMismatch,
207 "Unexpected number of fields. The first line declared " 209 "fields while the current line has "+
225 "Strict validation requires " 226 "trailing EOL in the last line as well");
241 info.second.first,
info.second.second);
252GetMyStream().x_ClearTraitsProvidedFieldsInfo();
264 if(GetMyStream().GetCurrentLineNo() < 1) {
267 "Strict validation requires " 268 "non empty data source with at least " 269 "two lines (a nameline and a record)");
295 for(
const auto& name :
m_Tokens) {
299 "Empty field names are not allowed");
302 string(name.data(), name.length()));
311 for(
const auto&
info: GetMyStream().GetFieldsMetaInfo()) {
312 if(
info.is_type_initialized) {
313 autofield_type =
info.type.GetType();
317make_pair(field_type,
info.type.GetProps());
Exception specific to IANA TSV sources.
@ eNumberOfFieldsMismatch
virtual const char * GetErrCodeString(void) const override
Get error code interpreted as text.
NCBI_EXCEPTION_DEFAULT(CCRowReaderStream_IANA_TSV_Exception, CException)
static void ValidateBasicTypeFieldValue(const CTempString &str_value, ERR_FieldType field_type, const string &props)
ERR_Action Tokenize(const CTempString raw_line, vector< CTempString > &tokens)
Tokenize the raw line and put the tokens into the tokens vector.
ERR_Action Tokenize(const CTempString raw_line, vector< CTempString > &tokens)
bool m_LineHasTrailingEOL
void x_GetFieldTypesToValidate(void)
vector< CTempString > m_Tokens
@ eRR_ValidationMode_Default
@ eRR_ValidationMode_Strict
ERR_EventAction OnEvent(ERR_Event event, ERR_EventMode event_mode)
bool m_FieldNamesExtracted
CRowReaderStream_IANA_TSV()
~CRowReaderStream_IANA_TSV()
RR_TRAITS_PARENT_STREAM(CRowReaderStream_IANA_TSV)
void SetValidationMode(ERR_ValidationMode validation_mode)
map< size_t, pair< ERR_FieldType, string > > m_FieldsToValidate
size_t ReadRowData(CNcbiIstream &is, string *data)
TFieldNo m_NumberOfFields
void x_ExtractNames(const CTempString &raw_line)
ERR_Action Validate(CTempString raw_line, ERR_FieldValidationMode field_validation_mode)
ERR_ValidationMode m_ValidationMode
Partial specialization of the CRowReaderStream_CharDelimited<...> template for the case when the data...
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
TErrCode GetErrCode(void) const
Get error code.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
EErrCode
Error types that an application can generate.
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Uint4 TFieldNo
Field number (zero based)
ERR_FieldValidationMode
Whether to check validity of the fields (names and/or values)
@ eRR_FieldValidation
check that the field's value (or name) is valid
ERR_Action
Delimited stream traits use the ERR_Action members to instruct what should be done next.
@ eRR_Continue_Data
Continue processing this line, in full.
@ eRR_Skip
Skip this line.
ERR_EventAction
How to react to the potentially disruptive events.
@ eRR_EventAction_Continue
Resume processing.
@ eRR_EventAction_Default
Do some default action.
ERR_EventMode
Indicate whether the "ERR_Event" event (passed to the OnEvent() callback) occured during regular read...
@ eRR_EventMode_Validating
We are performing data validation.
ERR_Event
CRowReader passes such events to the Traits via OnEvent() callback.
@ eRR_Event_SourceEnd
Data source has hit EOF.
@ eRR_Event_SourceBegin
Data source has started or been switched (no reads yet though).
@ eRR_Event_SourceError
Data source has hit an error on read.
const size_t kReadBufferSize
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4