📄 datatool.cpp
字号:
// Set DTD file name (default prefix is added in any case) if( const CArgValue& dn = args["dn"] ) { os->SetDTDFileName(dn.AsString()); } } CObjectStreamCopier copier(*in, *out); copier.Copy(typeInfo, CObjectStreamCopier::eNoFileHeader); } else { // skip in->Skip(typeInfo, CObjectIStream::eNoFileHeader); } } return true;}bool CDataTool::GenerateCode(void){ const CArgs& args = GetArgs(); // load generator config if ( const CArgValue& od = args["od"] ) generator.LoadConfig(od.AsString(), args["odi"], args["odw"]); //if ( const CArgValue& oD = args["oD"] ) // generator.AddConfigLine(oD.AsString()); // set list of types for generation if ( args["oX"] ) generator.ExcludeRecursion(); if ( args["oA"] ) generator.IncludeAllMainTypes(); if ( const CArgValue& ot = args["ot"] ) generator.IncludeTypes(ot.AsString()); if ( const CArgValue& ox = args["ox"] ) generator.ExcludeTypes(ox.AsString()); if ( !generator.HaveGenerateTypes() ) return true; // set the export specifier, if provided if ( const CArgValue& oex = args["oex"] ) { string ex; ex = generator.GetConfig().Get("-","_export"); if (ex.empty()) { ex = oex.AsString(); } CClassCode::SetExportSpecifier(ex); } // define the Doxygen group { if ( args["oDc"] ) { CClassCode::SetDoxygenComments(true); if ( const CArgValue& odx = args["odx"] ) { string root = odx.AsString(); if (root.empty()) { // default root = "http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/lxr/source"; } CClassCode::SetDocRootURL(root); } string group = generator.GetConfig().Get("-","_addtogroup_name"); CClassCode::SetDoxygenGroup(group); group = generator.GetConfig().Get("-","_ingroup_name"); generator.SetDoxygenIngroup(group); group = generator.GetConfig().Get("-","_addtogroup_description"); generator.SetDoxygenGroupDescription(group); } else { CClassCode::SetDoxygenComments(false); } } // prepare generator // set namespace if ( const CArgValue& on = args["on"] ) generator.SetDefaultNamespace(on.AsString()); // set output files if ( const CArgValue& oc = args["oc"] ) { const string& fileName = oc.AsString(); generator.SetCombiningFileName(fileName); generator.SetFileListFileName(fileName+".files"); } if ( const CArgValue& of = args["of"] ) generator.SetFileListFileName(of.AsString()); // set directories if ( const CArgValue& oph = args["oph"] ) generator.SetHPPDir(oph.AsString()); if ( const CArgValue& opc = args["opc"] ) generator.SetCPPDir(opc.AsString()); // set file names prefixes if ( const CArgValue& orF = args["or"] ) generator.SetFileNamePrefix(orF.AsString()); if ( args["orq"] ) generator.UseQuotedForm(true); if ( args["ocvs"] ) generator.CreateCvsignore(true); if ( args["ors"] ) generator.SetFileNamePrefixSource(eFileName_FromSourceFileName); if ( args["orm"] ) generator.SetFileNamePrefixSource(eFileName_FromModuleName); if ( args["orA"] ) generator.SetFileNamePrefixSource(eFileName_UseAllPrefixes); // precompiled header if ( const CArgValue& pch = args["pch"] ) CFileCode::SetPchHeader(pch.AsString()); // generate code generator.GenerateCode(); return true;}SourceFile::EType CDataTool::LoadDefinitions( CFileSet& fileSet, const list<string>& modulesPath, const string& nameList, SourceFile::EType srctype){ SourceFile::EType moduleType; list<string> names; NStr::Split(nameList, " ", names); ITERATE ( list<string>, fi, names ) { const string& name = *fi; if ( !name.empty() ) { SourceFile fName(name, modulesPath); moduleType = fName.GetType();// if first module has unknown type - assume ASN if (srctype == SourceFile::eUnknown) { if (moduleType == SourceFile::eUnknown) { moduleType = SourceFile::eASN; } srctype = moduleType; }// if second module has unknown type - assume same as the previous one else { if (moduleType == SourceFile::eUnknown) { moduleType = srctype; }// if modules have different types - exception else if (moduleType != srctype) { NCBI_THROW(CDatatoolException,eWrongInput, "Unable to process modules of different types" " simultaneously: "+name); } } switch (moduleType) { default: NCBI_THROW(CDatatoolException,eWrongInput,"Unknown file type: "+name); case SourceFile::eASN: { ASNLexer lexer(fName); lexer.AllowIDsEndingWithMinus(GetArgs()["lax_syntax"]); ASNParser parser(lexer); fileSet.AddFile(parser.Modules(name)); } break; case SourceFile::eDTD: { DTDLexer lexer(fName); DTDParser parser(lexer); fileSet.AddFile(parser.Modules(name)); } break; } } } return srctype;}END_NCBI_SCOPEint main(int argc, const char* argv[]){ USING_NCBI_SCOPE; CException::EnableBackgroundReporting(false); return CDataTool().AppMain(argc, argv, 0, eDS_Default, 0, "datatool");}/** ===========================================================================** $Log: datatool.cpp,v $* Revision 1000.2 2004/06/01 19:42:43 gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.72** Revision 1.72 2004/05/17 21:03:13 gorelenk* Added include of PCH ncbi_pch.hpp** Revision 1.71 2004/05/17 14:50:54 gouriano* Added possibility to include precompiled header** Revision 1.70 2004/05/03 19:31:03 gouriano* Made generation of DOXYGEN-style comments optional** Revision 1.69 2004/04/29 20:11:39 gouriano* Generate DOXYGEN-style comments in C++ headers** Revision 1.68 2004/03/19 15:45:19 gouriano* corrected fxs argument description** Revision 1.67 2003/06/16 14:41:05 gouriano* added possibility to convert DTD to XML schema** Revision 1.66 2003/05/29 17:26:49 gouriano* added possibility of generation .cvsignore file** Revision 1.65 2003/05/23 19:18:39 gouriano* modules of unknown type are assumed to be ASN* all modules must have the same type** Revision 1.64 2003/05/23 13:54:48 gouriano* throw exception on unknown module file type** Revision 1.63 2003/05/14 14:42:22 gouriano* added generation of XML schema** Revision 1.62 2003/03/11 20:06:47 kuznets* iterate -> ITERATE** Revision 1.61 2003/03/10 18:55:18 gouriano* use new structured exceptions (based on CException)** Revision 1.60 2003/02/24 21:57:46 gouriano* added odw flag - to issue a warning about missing DEF file** Revision 1.59 2003/02/10 17:56:15 gouriano* make it possible to disable scope prefixes when reading and writing objects generated from ASN specification in XML format, or when converting an ASN spec into DTD.** Revision 1.58 2002/12/31 20:14:24 gouriano* corrected usage of export specifiers when generating C++ classes** Revision 1.57 2002/12/23 18:40:07 dicuccio* Added new command-line option: -oex <export-specifier> for adding WIn32 export* specifiers to generated objects.** Revision 1.56 2002/10/22 15:06:12 gouriano* added possibillity to use quoted syntax form for generated include files** Revision 1.55 2002/10/15 13:57:09 gouriano* recognize DTD files and handle them using DTD lexer/parser** Revision 1.54 2002/09/26 16:57:31 vasilche* Added flag for compatibility with asntool** Revision 1.53 2002/08/06 17:03:48 ucko* Let -opm take a comma-delimited list; move relevant CVS logs to end.** Revision 1.52 2001/12/13 19:32:41 juran* Make main()'s argv of type (const char*), for use with jTools.** Revision 1.51 2001/10/17 18:19:52 grichenk* Updated to use CObjectOStreamXml::GetFileXXX** Revision 1.50 2001/04/16 17:53:45 kholodov* Added: Option -dn to specify the DTD file name in XML header** Revision 1.49 2000/12/26 22:24:53 vasilche* Updated for new behaviour of CNcbiArgs.** Revision 1.48 2000/12/12 17:57:06 vasilche* Avoid using of new C++ keywords ('or' in this case).** Revision 1.47 2000/12/12 14:28:17 vasilche* Changed the way arguments are processed.** Revision 1.46 2000/11/27 18:19:47 vasilche* Datatool now conforms CNcbiApplication requirements.** Revision 1.45 2000/11/20 17:26:32 vasilche* Fixed warnings on 64 bit platforms.* Updated names of config variables.** Revision 1.44 2000/11/08 17:50:18 vasilche* Fixed compilation error on MSVC.** Revision 1.43 2000/11/08 17:02:51 vasilche* Added generation of modular DTD files.** Revision 1.42 2000/11/01 20:38:59 vasilche* OPTIONAL and DEFAULT are not permitted in CHOICE.* Fixed code generation for DEFAULT.** Revision 1.41 2000/09/29 16:18:28 vasilche* Fixed binary format encoding/decoding on 64 bit compulers.* Implemented CWeakMap<> for automatic cleaning map entries.* Added cleaning local hooks via CWeakMap<>.* Renamed ReadTypeName -> ReadFileHeader, ENoTypeName -> ENoFileHeader.* Added some user interface methods to CObjectIStream, CObjectOStream and* CObjectStreamCopier.** Revision 1.40 2000/09/26 17:38:26 vasilche* Fixed incomplete choiceptr implementation.* Removed temporary comments.** Revision 1.39 2000/09/18 20:00:28 vasilche* Separated CVariantInfo and CMemberInfo.* Implemented copy hooks.* All hooks now are stored in CTypeInfo/CMemberInfo/CVariantInfo.* Most type specific functions now are implemented via function pointers instead of virtual functions.** Revision 1.38 2000/09/18 13:53:00 vasilche* Fixed '.files' extension.** Revision 1.37 2000/09/01 13:16:27 vasilche* Implemented class/container/choice iterators.* Implemented CObjectStreamCopier for copying data without loading into memory.** Revision 1.36 2000/08/25 15:59:20 vasilche* Renamed directory tool -> datatool.** Revision 1.35 2000/07/10 17:32:00 vasilche* Macro arguments made more clear.* All old ASN stuff moved to serialasn.hpp.* Changed prefix of enum info functions to GetTypeInfo_enum_.** Revision 1.34 2000/06/16 16:31:39 vasilche* Changed implementation of choices and classes info to allow use of the same classes in generated and user written classes.** Revision 1.33 2000/05/24 20:09:29 vasilche* Implemented DTD generation.** Revision 1.32 2000/04/28 16:58:16 vasilche* Added classes CByteSource and CByteSourceReader for generic reading.* Added delayed reading of choice variants.** Revision 1.31 2000/04/13 17:30:37 vasilche* Avoid INTERNAL COMPILER ERROR on MSVC.* Problem is in "static inline" function which cannot be expanded inline.** Revision 1.30 2000/04/13 14:50:36 vasilche* Added CObjectIStream::Open() and CObjectOStream::Open() for easier use.** Revision 1.29 2000/04/12 15:36:51 vasilche* Added -on <namespace> argument to datatool.* Removed unnecessary namespace specifications in generated files.** Revision 1.28 2000/04/07 19:26:28 vasilche* Added namespace support to datatool.* By default with argument -oR datatool will generate objects in namespace* NCBI_NS_NCBI::objects (aka ncbi::objects).* Datatool's classes also moved to NCBI namespace.** Revision 1.27 2000/03/10 17:59:31 vasilche* Fixed error reporting.** Revision 1.26 2000/02/01 21:48:01 vasilche* Added CGeneratedChoiceTypeInfo for generated choice classes.* Removed CMemberInfo subclasses.* Added support for DEFAULT/OPTIONAL members.* Changed class generation.* Moved datatool headers to include/internal/serial/tool.** Revision 1.25 2000/01/06 16:13:43 vasilche* Updated help messages.** Revision 1.24 1999/12/30 21:33:39 vasilche* Changed arguments - more structured.* Added intelligence in detection of source directories.** Revision 1.23 1999/12/28 18:55:58 vasilche* Reduced size of compiled object files:* 1. avoid inline or implicit virtual methods (especially destructors).* 2. avoid std::string's methods usage in inline methods.* 3. avoid string literals ("xxx") in inline methods.** Revision 1.22 1999/12/21 17:18:35 vasilche* Added CDelayedFostream class which rewrites file only if contents is changed.** Revision 1.21 1999/12/20 21:00:18 vasilche* Added generation of sources in different directories.** Revision 1.20 1999/12/01 17:36:26 vasilche* Fixed CHOICE processing.** Revision 1.19 1999/11/15 20:01:34 vasilche* Fixed GCC error** Revision 1.18 1999/11/15 19:36:16 vasilche* Fixed warnings on GCC** ===========================================================================*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -