68 virtual void Init(
void);
69 virtual int Run (
void);
73 void Setup(
const CArgs& args);
76 void ProcessOneFile(
const string& current_file);
77 bool ProcessOneDirectory(
const CDir& directory,
const CMask&
mask,
bool recurse);
105 m_LogStream(0), m_output(0),
106 m_comma_separated(
false),
109 m_ignore_unknown_types(
false)
112 #ifdef NCBI_PRODUCTION_VER
130 arg_desc->AddOptionalKey
131 (
"p",
"Directory",
"Path to input files",
134 arg_desc->AddOptionalKey
135 (
"r",
"Directory",
"Path to results",
138 arg_desc->AddOptionalKey
139 (
"i",
"InFile",
"Single Input File",
142 arg_desc->AddOptionalKey(
143 "o",
"OutFile",
"Single Output File",
146 arg_desc->AddDefaultKey
149 arg_desc->AddFlag(
"E",
"Recurse");
151 arg_desc->AddFlag(
"no-header",
"Start from the first row");
152 arg_desc->AddFlag(
"skip-empty",
"Ignore all empty rows");
153 arg_desc->AddFlag(
"ignore-unknown",
"Ignore all unknown types");
156 arg_desc->AddFlag(
"comma",
"Use comma separator instead of tabs");
160 arg_desc->AddOptionalKey(
"required",
"String",
"Comma separated required columns, use indices or names",
CArgDescriptions::eString);
162 arg_desc->AddOptionalKey(
"ignore",
"String",
"Comma separated columns to be ignored, use indices or names",
CArgDescriptions::eString);
164 arg_desc->AddOptionalKey(
"unique",
"String",
165 "Comma separated columns needs to be unique in file, use indices or names",
170 arg_desc->AddOptionalKey(
"discouraged",
"String",
"Comma separated list of discouraged types",
CArgDescriptions::eString);
176 arg_desc->AddFlag(
"print-supported",
"Show supported data types");
179 string prog_description =
"Validates tab delimited files against ASN.1 data types\n";
180 arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),
181 prog_description,
false);
184 SetupArgDescriptions(arg_desc.release());
206 if (args[
"print-supported"])
218 if (args[
"required"])
238 m_format = args[
"format"].AsString();
241 if (args[
"discouraged"])
247 if (args[
"require-one"])
255 m_output = &args[
"o"].AsOutputFile();
280 CDir directory(args[
"p"].AsString());
284 masks.
Add(
"*" +args[
"x"].AsString());
361 "File " + current_file +
" does not exists"));
366 unique_ptr<CNcbiOfstream> local_output;
374 string temp_file = current_file.substr(0, current_file.rfind(
'.'));
376 local_file.
Reset(temp_file);
378 output = local_output.get();
394 if (local_output.get())
405 unique_ptr<CDir::TEntries>
entries(e);
407 for (CDir::TEntries::const_iterator it = e->begin(); it != e->end(); it++)
412 if (
mask.Match((*it)->GetPath()))
448 int main(
int argc,
const char* argv[])
void PrintSupported(CNcbiOstream &out_stream) const
static CColumnValidatorRegistry & GetInstance()
static CLineError * Create(EProblem eProblem, EDiagSev eSeverity, const std::string &strSeqId, unsigned int uLine, const std::string &strFeatureName=string(""), const std::string &strQualifierName=string(""), const std::string &strQualifierValue=string(""), const std::string &strErrorMessage=string(""), const TVecOfLines &vecOfOtherLines=TVecOfLines())
Use this because the constructor is protected.
virtual void SetProgressOstream(CNcbiOstream *pProgressOstrm, ENcbiOwnership eNcbiOwnership=eNoOwnership)
This sets the stream to which progress messages are written.
size_t LevelCount(EDiagSev eSev) override
Returns the number of errors seen so far at the given severity.
size_t Count() const override
CNcbiOstream * m_LogStream
void ProcessOneFile(CNcbiIstream &input, CNcbiOstream *output)
void Setup(const CArgs &args)
CRef< CMessageListenerBase > m_logger
CArgValue::TStringArray m_require_one
string m_ResultsDirectory
bool m_ignore_unknown_types
bool ProcessOneDirectory(const CDir &directory, const CMask &mask, bool recurse)
static void RegisterAliases(CNcbiIstream *in_stream)
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)
@ e_tab_ignore_unknown_types
@ e_tab_ignore_empty_rows
void GenerateOutput(CNcbiOstream *out_stream, bool no_headers)
virtual bool PutError(const ILineError &)=0
Store error in the container, and return true if error was stored fine, and return false if the calle...
@ eProblem_GeneralParsingError
Include a standard set of the NCBI C++ Toolkit most basic headers.
static SQLCHAR output[256]
vector< string > TStringArray
Some values types can contain several value lists.
@ fAllowMultiple
Repeated key arguments are legal (use with AddKey)
@ eInputFile
Name of file (must exist and be readable)
@ eString
An arbitrary string.
@ eOutputFile
Name of file (must be writable)
@ eDS_Default
Try standard log file (app.name + ".log") in /log/, use stderr on failure.
@ eDiag_Error
Error message.
@ eDiag_Warning
Warning message.
@ eDiag_Fatal
Fatal error – guarantees exit(or abort)
@ eDiag_Critical
Critical error message.
const string & GetMsg(void) const
Get message string.
virtual bool Remove(TRemoveFlags flags=eRecursive) const
Remove a directory entry.
static string AddTrailingPathSeparator(const string &path)
Add trailing path separator, if needed.
virtual bool Exists(void) const
Check if directory "dirname" exists.
void Reset(const string &path)
Reset path string.
bool Create(TCreateFlags flags=fCreate_Default) const
Create the directory using "dirname" passed in the constructor.
TEntries * GetEntriesPtr(const string &mask=kEmptyStr, TGetEntriesFlags flags=0) const
Get directory entries based on the specified "mask".
const string & GetPath(void) const
Get entry path.
@ fIgnoreRecursive
Suppress "self recursive" elements (the directories "." and "..").
@ fCreateObjects
Create appropriate subclasses of CDirEntry (CFile,CDir,...), not just CDirEntry objects.
static CRef< ILineReader > New(const string &filename)
Return a new ILineReader object corresponding to the given filename, taking "-" (but not "....
void Reset(void)
Reset reference object.
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
static string & ToLower(string &str)
Convert string to lower case – string& version.
void Run(void)
Enter the main loop.
LOG LOG_cxx2c(void)
Create LOG on top of C++ Toolkit CNcbiDiag.
void CORE_SetREG(REG rg)
Set the registry (no registry if "rg" is passed zero) – to be used by the core internals.
REG REG_cxx2c(IRWRegistry *reg, bool pass_ownership=false)
Convert a C++ Toolkit registry object to a REG registry.
void CORE_SetLOG(LOG lg)
Set the log handle (no logging if "lg" is passed zero) – to be used by the core internals (CORE LOG).
void Add(const string &mask)
Add an inclusion mask.
Lightweight interface for getting lines of data with minimal memory copying.
Magic spell ;-) needed for some weird compilers... very empiric.
Classes to match a string against a set of masks.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
#define GetArgs
Avoid preprocessor name clash with the NCBI C Toolkit.
Defines command line argument related classes.
Defines unified interface to application:
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
int main(int argc, const char *argv[])
const char * TABLEVAL_APP_VER
static wxAcceleratorEntry entries[3]