NCBI C++ ToolKit
generate.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: generate.cpp 98952 2023-01-26 12:56:13Z gouriano $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Eugene Vasilchenko
27 *
28 * File Description:
29 * Main generator: collects all types, classes and files.
30 */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbifile.hpp>
34 #include <algorithm>
35 #include <typeinfo>
36 #include "moduleset.hpp"
37 #include "module.hpp"
38 #include "type.hpp"
39 #include "statictype.hpp"
40 #include "reftype.hpp"
41 #include "unitype.hpp"
42 #include "enumtype.hpp"
43 #include "blocktype.hpp"
44 #include "choicetype.hpp"
45 #include "filecode.hpp"
46 #include "generate.hpp"
47 #include "exceptions.hpp"
48 #include "fileutil.hpp"
49 #include "rpcgen.hpp"
50 #include "code.hpp"
51 #include "classstr.hpp"
52 #include <serial/error_codes.hpp>
53 
54 
55 #define NCBI_USE_ERRCODE_X Serial_MainGen
56 
58 
60  : m_ExcludeRecursion(false), m_FileNamePrefixSource(eFileName_FromNone)
61 {
64  m_UseQuotedForm = false;
65  m_CreateCvsignore = false;
66 }
67 
69 {
70 }
71 
73 {
74  return m_Config;
75 }
76 
78 {
79  return m_FileNamePrefix;
80 }
81 
83 {
84  m_UseQuotedForm = use;
85 }
86 
88 {
89  m_CreateCvsignore = create;
90 }
91 
93 {
95 }
96 
98 {
100 }
101 
103 {
106 }
107 
109  const string& name) const
110 {
111  return ExternalResolve(module, name);
112 }
113 
115 {
116  return m_DefaultNamespace;
117 }
118 
120 {
121  m_DefaultNamespace = ns;
122 }
123 
125 {
127 }
128 
130 {
131  m_Config.Read(in);
132 }
133 
134 void CCodeGenerator::LoadConfig(const string& fileName,
135  bool ignoreAbsense, bool warningAbsense)
136 {
137  m_DefFile.erase();
138  // load descriptions from registry file
139  if ( fileName == "stdin" || fileName == "-" ) {
141  }
142  else {
143  CNcbiIfstream in(fileName.c_str());
144  if ( !in ) {
145  if ( ignoreAbsense ) {
146  return;
147  } else if (warningAbsense) {
148  ERR_POST_X(1, Warning << "cannot open file " << fileName);
149  } else {
150  ERR_POST_X(2, Fatal << "cannot open file " << fileName);
151  }
152  }
153  else {
154  m_DefFile = fileName;
155  LoadConfig(in);
156  }
157  }
158 }
159 
160 void CCodeGenerator::AddConfigLine(const string& line)
161 {
162  SIZE_TYPE bra = line.find('[');
163  SIZE_TYPE ket = line.find(']');
164  SIZE_TYPE eq = line.find('=', ket + 1);
165  if ( bra != 0 || ket == NPOS || eq == NPOS )
166  ERR_POST_X(3, Fatal << "bad config line: " << line);
167 
168  m_Config.Set(line.substr(bra + 1, ket - bra - 1),
169  line.substr(ket + 1, eq - ket - 1),
170  line.substr(eq + 1));
171 }
172 
174  const string& name,
175  bool exported) const
176 {
177  string loc("CCodeGenerator::ExternalResolve: failed");
178  try {
179  return m_MainFiles.ExternalResolve(module, name, exported);
180  }
181  catch ( CAmbiguiousTypes& exc) {
182  _TRACE(exc.what());
183  NCBI_RETHROW_SAME(exc,loc);
184  }
185  catch ( CNotFoundException& _DEBUG_ARG(exc)) {
186  _TRACE(exc.what());
187  return m_ImportFiles.ExternalResolve(module, name, exported);
188  }
189  return NULL; // Eliminate "return value expected" warning
190 }
191 
193  bool exported) const
194 {
195  string loc("CCodeGenerator::ResolveInAnyModule: failed");
196  try {
197  return m_MainFiles.ResolveInAnyModule(name, exported);
198  }
199  catch ( CAmbiguiousTypes& exc) {
200  _TRACE(exc.what());
201  NCBI_RETHROW_SAME(exc,loc);
202  }
203  catch ( CNotFoundException& _DEBUG_ARG(exc)) {
204  _TRACE(exc.what());
205  return m_ImportFiles.ResolveInAnyModule(name, exported);
206  }
207  return NULL; // Eliminate "return value expected" warning
208 }
209 
210 CDataType* CCodeGenerator::ResolveMain(const string& fullName) const
211 {
212  SIZE_TYPE dot = fullName.find('.');
213  if ( dot != NPOS ) {
214  // module specified
215  return m_MainFiles.ExternalResolve(fullName.substr(0, dot),
216  fullName.substr(dot + 1),
217  true);
218  }
219  else {
220  // module not specified - we'll scan all modules for type
221  return m_MainFiles.ResolveInAnyModule(fullName, true);
222  }
223 }
224 
225 const string& CCodeGenerator::ResolveFileName(const string& name) const
226 {
228  if (i != m_Files.end()) {
229  return i->second->GetFileBaseName();
230  }
231  return name;
232 }
233 
235 {
237  ITERATE ( CFileModules::TModules, mi, (*msi)->GetModules() ) {
238  const CDataTypeModule* module = mi->get();
240  module->GetDefinitions() ) {
241  const string& name = ti->first;
242  const CDataType* type = ti->second.get();
243  if ( !name.empty() && !type->Skipped() ) {
244  m_GenerateTypes.insert(module->GetName() + '.' + name);
245  }
246  }
247  }
248  }
249 }
250 
251 void CCodeGenerator::GetTypes(TTypeNames& typeSet, const string& types)
252 {
253  SIZE_TYPE pos = 0;
254  SIZE_TYPE next = types.find(',');
255  while ( next != NPOS ) {
256  typeSet.insert(types.substr(pos, next - pos));
257  pos = next + 1;
258  next = types.find(',', pos);
259  }
260  typeSet.insert(types.substr(pos));
261 }
262 
263 bool CCodeGenerator::Check(void) const
264 {
266  m_MainFiles.Check();
267 }
268 
269 void CCodeGenerator::ExcludeTypes(const string& typeList)
270 {
271  TTypeNames typeNames;
272  GetTypes(typeNames, typeList);
273  ITERATE ( TTypeNames, i, typeNames ) {
274  m_Config.Set(*i, "_class", "-");
276  }
277 }
278 
279 void CCodeGenerator::IncludeTypes(const string& typeList)
280 {
281  GetTypes(m_GenerateTypes, typeList);
282 }
283 
285 {
286  bool operator()(const string& s1, const string& s2) const
287  {
288  return (NStr::CompareNocase(s1, s2) < 0);
289  }
290 };
291 
293 {
294  if ( m_FileListFileName.empty() ) {
295  return;
296  }
297  string fileName( MakeAbsolutePath(
299  CNcbiIfstream fileList(fileName.c_str());
300  if ( fileList.is_open() ) {
301  string strline;
302  string fileroot;
303  while ( NcbiGetlineEOL(fileList, strline) ) {
304  if ( !NStr::StartsWith(strline, "GENFILES =") ) {
305  continue;
306  }
307  NStr::ReplaceInPlace(strline,"GENFILES =","");
308  list<string> files;
310  ITERATE(list<string>, f, files) {
311  CFile fo;
312  fo.Reset( MakeAbsolutePath( Path(m_HPPDir, *f)) + "_.hpp");
313  if (fo.Exists()) {
314  fo.Remove();
315  }
316  fo.Reset( MakeAbsolutePath( Path(m_CPPDir, *f)) + "_.cpp");
317  if (fo.Exists()) {
318  fo.Remove();
319  }
320  }
321  }
322  fileList.close();
323  CFile fo(fileName);
324  if (fo.Exists()) {
325  fo.Remove();
326  }
327  }
328 }
329 
331 {
333  ITERATE ( TOutputFiles, filei, m_Files ) {
334  CFileCode* code = filei->second.get();
335  string fname;
336  for ( fname = code->GetFileBaseName();
337  names.find(fname) != names.end();) {
338  fname = code->ChangeFileBaseName();
339  }
340  names.insert(fname);
341  }
342 }
343 
345 {
346  // collect types
349  }
350  CheckFileNames();
351 
352  // generate output files
353  string outdir_cpp, outdir_hpp;
354  list<string> listGenerated, listUntouched;
355  list<string> allGeneratedHpp, allGeneratedCpp, allSkippedHpp, allSkippedCpp;
356  map<string, pair<string,string> > module_names;
357  ITERATE ( TOutputFiles, filei, m_Files ) {
358  CFileCode* code = filei->second.get();
359  code->GetModuleNames( module_names);
360  code->UseQuotedForm(m_UseQuotedForm);
361  code->GenerateCode();
362  string fileName;
363  code->GenerateHPP(m_HPPDir, fileName);
364  allGeneratedHpp.push_back(fileName);
365  if (outdir_hpp.empty()) {
366  CDirEntry entry(fileName);
367  outdir_hpp = entry.GetDir();
368  }
369  code->GenerateCPP(m_CPPDir, fileName);
370  allGeneratedCpp.push_back(fileName);
371  if (outdir_cpp.empty()) {
372  CDirEntry entry(fileName);
373  outdir_cpp = entry.GetDir();
374  }
375  if (code->GenerateUserHPP(m_HPPDir, fileName)) {
376  listGenerated.push_back( fileName);
377  allGeneratedHpp.push_back(fileName);
378  } else {
379  listUntouched.push_back( fileName);
380  allSkippedHpp.push_back(fileName);
381  }
382  if (code->GenerateUserCPP(m_CPPDir, fileName)) {
383  listGenerated.push_back( fileName);
384  allGeneratedCpp.push_back(fileName);
385  } else {
386  listUntouched.push_back( fileName);
387  allSkippedCpp.push_back(fileName);
388  }
389  }
390  list<string> module_inc, module_src;
393  GenerateClientCode(listGenerated);
394 
395  GenerateDoxygenGroupDescription(module_names);
396  GenerateCombiningFile(module_inc, module_src, allGeneratedHpp, allGeneratedCpp);
397  listGenerated.insert(listGenerated.end(), module_inc.begin(), module_inc.end());
398  allGeneratedHpp.insert(allGeneratedHpp.end(), module_inc.begin(), module_inc.end());
399  listGenerated.insert(listGenerated.end(), module_src.begin(), module_src.end());
400  allGeneratedCpp.insert(allGeneratedCpp.end(), module_src.begin(), module_src.end());
401  GenerateFileList(listGenerated, listUntouched,
402  allGeneratedHpp, allGeneratedCpp, allSkippedHpp, allSkippedCpp);
403  GenerateCvsignore(outdir_cpp, outdir_hpp, listGenerated, module_names);
404 }
405 
406 
408  map<string, pair<string,string> >& module_names)
409 {
410  if (!CClassCode::GetDoxygenComments() || module_names.empty()) {
411  return;
412  }
413  string ingroup_name =
414  m_DoxygenIngroup.empty() ? "DatatoolGeneratedClasses" : m_DoxygenIngroup;
415  CDirEntry entry(GetMainModules().GetModuleSets().front()->GetSourceFileName());
416  string fileName = MakeAbsolutePath(
417  Path(m_HPPDir, Path(m_FileNamePrefix, entry.GetBase() + "_doxygen.h")));
418  CNcbiOfstream doxyfile(fileName.c_str());
419  if ( doxyfile.is_open() ) {
421  doxyfile <<
422  " * File Description:\n"
423  " * This file was generated by application DATATOOL\n"
424  " * It contains comment blocks for DOXYGEN metamodules\n"
425  " *\n"
426  " * ===========================================================================\n"
427  " */\n";
430  for (i = module_names.begin(); i != module_names.end(); ++i) {
431  doxyfile << "\n\n/** @defgroup dataspec_" << i->second.second << " ";
432  if (m_DoxygenGroupDescription.empty()) {
433  doxyfile << "Code generated by DATATOOL from "
434  << i->second.first << " (module \'" << i->first << "\')";
435  } else {
436  doxyfile << m_DoxygenGroupDescription;
437  }
438  doxyfile << "\n * @ingroup " << ingroup_name << "\n */\n\n";
439  }
440  } else {
441  doxyfile << "\n\n/** @defgroup ";
442  doxyfile << CClassCode::GetDoxygenGroup() << " ";
443  if (m_DoxygenGroupDescription.empty()) {
444  doxyfile << "Code generated by DATATOOL";
445  } else {
446  doxyfile << m_DoxygenGroupDescription;
447  }
448  doxyfile << "\n * @ingroup " << ingroup_name << "\n */\n\n";
449  }
450  }
451 }
452 
453 
455  const list<string>& generated, const list<string>& untouched,
456  list<string>& allGeneratedHpp, list<string>& allGeneratedCpp,
457  list<string>& allSkippedHpp, list<string>& allSkippedCpp)
458 {
459  if ( m_FileListFileName.empty() ) {
460  return;
461  }
462  string fileName( MakeAbsolutePath(
464  CNcbiOfstream fileList(fileName.c_str());
465  if ( !fileList ) {
466  ERR_POST_X(4, Fatal <<
467  "cannot create file list file: " << m_FileListFileName);
468  }
469 
470  fileList << "GENFILES =";
471  {
472  ITERATE ( TOutputFiles, filei, m_Files ) {
473  string tmp(filei->second->GetFileBaseName());
474 #if defined(NCBI_OS_MSWIN)
475  tmp = NStr::Replace(tmp,"\\","/");
476 #endif
477  fileList << ' ' << tmp;
478  }
479  }
480  fileList << "\n";
481  fileList << "GENFILES_LOCAL =";
482  {
483  ITERATE ( TOutputFiles, filei, m_Files ) {
484  fileList << ' ' << BaseName(
485  filei->second->GetFileBaseName());
486  }
487  }
488  fileList << "\n";
489 
490  // generation report
491  for (int user=0; user<2; ++user) {
492  for (int local=0; local<2; ++local) {
493  for (int cpp=0; cpp<2; ++cpp) {
494  fileList << (user ? "SKIPPED" : "GENERATED") << "_"
495  << (cpp ? "CPP" : "HPP") << (local ? "_LOCAL" : "") << " =";
496  const list<string> *lst = (user ? &untouched : &generated);
497  for (list<string>::const_iterator i=lst->begin();
498  i != lst->end(); ++i) {
499  CDirEntry entry(*i);
500  bool is_cpp = (NStr::CompareNocase(entry.GetExt(),".cpp")==0);
501  if ((is_cpp && cpp) || (!is_cpp && !cpp)) {
502  fileList << ' ';
503  if (local) {
504  fileList << entry.GetBase();
505  } else {
506  string pp = entry.GetPath();
507  size_t found;
508  if (is_cpp) {
509  if (!m_CPPDir.empty() &&
510  (found = pp.find(m_CPPDir)) == 0) {
511  pp.erase(0,m_CPPDir.length()+1);
512  }
513  } else {
514  if (!m_HPPDir.empty() &&
515  (found = pp.find(m_HPPDir)) == 0) {
516  pp.erase(0,m_HPPDir.length()+1);
517  }
518  }
521 #if defined(NCBI_OS_MSWIN)
522  tmp = NStr::Replace(tmp,"\\","/");
523 #endif
524  fileList << tmp << ent.GetBase();
525  }
526  }
527 
528  }
529  fileList << endl;
530  }
531  }
532  }
533 
534  string flist, flist_local;
535  ITERATE( list<string>, p, allGeneratedHpp) {
536  string tmp(*p);
537  flist_local += ' ' + CDirEntry(tmp).GetName();
538  if (!m_HPPDir.empty() && tmp.find(m_HPPDir) == 0) {
539  tmp.erase(0,m_HPPDir.length()+1);
540  }
542 #if defined(NCBI_OS_MSWIN)
543  tmp = NStr::Replace(tmp,"\\","/");
544 #endif
545  flist += ' ' +tmp;
546  }
547  fileList << "ALLGENERATED_HPP =" << flist << '\n';
548  fileList << "ALLGENERATED_HPP_LOCAL =" << flist_local << '\n';
549 
550  flist.erase(); flist_local.erase();
551  ITERATE( list<string>, p, allSkippedHpp) {
552  string tmp(*p);
553  flist_local += ' ' + CDirEntry(tmp).GetName();
554  if (!m_HPPDir.empty() && tmp.find(m_HPPDir) == 0) {
555  tmp.erase(0,m_HPPDir.length()+1);
556  }
558 #if defined(NCBI_OS_MSWIN)
559  tmp = NStr::Replace(tmp,"\\","/");
560 #endif
561  flist += ' ' +tmp;
562  }
563  fileList << "ALLSKIPPED_HPP =" << flist << '\n';
564  fileList << "ALLSKIPPED_HPP_LOCAL =" << flist_local << '\n';
565 
566  flist.erase(); flist_local.erase();
567  ITERATE( list<string>, p, allGeneratedCpp) {
568  string tmp(*p);
569  flist_local += ' ' + CDirEntry(tmp).GetName();
570  if (!m_CPPDir.empty() && tmp.find(m_CPPDir) == 0) {
571  tmp.erase(0,m_CPPDir.length()+1);
572  }
574 #if defined(NCBI_OS_MSWIN)
575  tmp = NStr::Replace(tmp,"\\","/");
576 #endif
577  flist += ' ' +tmp;
578  }
579  fileList << "ALLGENERATED_CPP =" << flist << '\n';
580  fileList << "ALLGENERATED_CPP_LOCAL =" << flist_local << '\n';
581 
582  flist.erase(); flist_local.erase();
583  ITERATE( list<string>, p, allSkippedCpp) {
584  string tmp(*p);
585  flist_local += ' ' + CDirEntry(tmp).GetName();
586  if (!m_CPPDir.empty() && tmp.find(m_CPPDir) == 0) {
587  tmp.erase(0,m_CPPDir.length()+1);
588  }
590 #if defined(NCBI_OS_MSWIN)
591  tmp = NStr::Replace(tmp,"\\","/");
592 #endif
593  flist += ' ' +tmp;
594  }
595  fileList << "ALLSKIPPED_CPP =" << flist << '\n';
596  fileList << "ALLSKIPPED_CPP_LOCAL =" << flist_local << '\n';
597 
598 }
599 
601  const list<string>& module_inc, const list<string>& module_src,
602  list<string>& allHpp, list<string>& allCpp)
603 {
604  if ( m_CombiningFileName.empty() ) {
605  return;
606  }
607  // write combined files *__.cpp and *___.cpp
608  for ( int i = 0; i < 2; ++i ) {
609  const char* suffix = i? "_.cpp": ".cpp";
610  string fileName = m_CombiningFileName + "__" + suffix;
611  fileName = Path(m_CPPDir,Path(m_FileNamePrefix,fileName));
612  allCpp.push_back(fileName);
613  fileName = MakeAbsolutePath(fileName);
614  CNcbiOfstream out(fileName.c_str());
615  if ( !out )
616  ERR_POST_X(5, Fatal << "Cannot create file: "<<fileName);
617 
618  if (!CFileCode::GetPchHeader().empty()) {
619  out <<
620  "#include <" << CFileCode::GetPchHeader() << ">\n";
621  }
622 
623  ITERATE ( TOutputFiles, filei, m_Files ) {
624  out << "#include \""<<BaseName(
625  filei->second->GetFileBaseName())<<
626  suffix<<"\"\n";
627  }
628  if (i) {
629  ITERATE( list<string>, m, module_src) {
630  out << "#include \"" << CDirEntry(*m).GetBase() << ".cpp\"\n";
631  }
632  }
633 
634  out.close();
635  if ( !out )
636  ERR_POST_X(6, Fatal << "Error writing file "<<fileName);
637  }
638  // write combined *__.hpp file
639  const char* suffix = ".hpp";
640  // save to the includes directory
641  string fileName = Path(m_HPPDir, Path(m_FileNamePrefix,
642  m_CombiningFileName + "__" + suffix));
643  allHpp.push_back(fileName);
644  fileName = MakeAbsolutePath(fileName);
645 
646  CNcbiOfstream out(fileName.c_str());
647  if ( !out )
648  ERR_POST_X(7, Fatal << "Cannot create file: " << fileName);
649 
650  ITERATE ( TOutputFiles, filei, m_Files ) {
651  out << "#include " << (m_UseQuotedForm ? '\"' : '<') << GetStdPath(
653  filei->second->GetFileBaseName())) + suffix) <<
654  (m_UseQuotedForm ? '\"' : '>') << "\n";
655  }
656  ITERATE( list<string>, m, module_inc) {
657  out << "#include " << (m_UseQuotedForm ? '\"' : '<')
658  << GetStdPath(Path(m_FileNamePrefix, CDirEntry(*m).GetBase())) << ".hpp"
659  << (m_UseQuotedForm ? '\"' : '>') << "\n";
660  }
661 
662  out.close();
663  if ( !out )
664  ERR_POST_X(8, Fatal << "Error writing file " << fileName);
665 }
666 
667 bool CCodeGenerator::IsGitRepository(const string& dir) const
668 {
669  string rootdir = MakeAbsolutePath(GetRootDir());
670  string f, parent = MakeAbsolutePath(dir);
671  do {
672  f = parent;
673  string igit = Path(f, ".git");
674  string isvn = Path(f, ".svn");
675  if (CDirEntry(Path(f, ".git")).Exists()) {
676  return true;
677  }
678  if (CDirEntry(Path(f, ".svn")).Exists()) {
679  return false;
680  }
682  } while (parent != f && !f.empty() && f != rootdir);
683  return false;
684 }
685 
687  const string& outdir_cpp, const string& outdir_hpp,
688  const list<string>& generated, map<string, pair<string,string> >& module_names)
689 {
690  if (!m_CreateCvsignore) {
691  return;
692  }
693  string ignoreName(".cvsignore");
694  string extraName(".cvsignore.extra");
695  if (IsGitRepository(outdir_cpp)) {
696  ignoreName = ".gitignore";
697  }
698 
699  for (int i=0; i<2; ++i) {
700  bool is_cpp = (i==0);
701  string out_dir(is_cpp ? outdir_cpp : outdir_hpp);
702  string ignorePath(MakeAbsolutePath(Path(out_dir,ignoreName)));
703  string extraPath(MakeAbsolutePath(Path(out_dir,extraName)));
704  string strline;
705  set<string> files;
706 
707  if (CFile(ignorePath).Exists()) {
708  CNcbiIfstream ifs(ignorePath.c_str(), IOS_BASE::in);
709  if ( ifs ) {
710  while ( NcbiGetlineEOL(ifs, strline) ) {
711  files.insert(NStr::TruncateSpaces(strline));
712  }
713  }
714  } else {
715  files.insert(ignoreName);
716  }
717 
718 // .cvsignore.extra
719  if (CFile(extraPath).Exists()) {
720  CNcbiIfstream ifs(extraPath.c_str(), IOS_BASE::in);
721  if ( ifs ) {
722  while ( NcbiGetlineEOL(ifs, strline) ) {
723  files.insert(NStr::TruncateSpaces(strline));
724  }
725  }
726  }
727 
728 // base classes (always generated)
729  ITERATE ( TOutputFiles, filei, m_Files ) {
730  strline = BaseName(filei->second->GetFileBaseName()) + "_." + (is_cpp ? "cpp" : "hpp");
731  files.insert(strline);
732  }
733 
734 // user classes
735  for (list<string>::const_iterator it = generated.begin();
736  it != generated.end(); ++it) {
737  CDirEntry entry(*it);
738  if (is_cpp == (NStr::CompareNocase(entry.GetExt(),".cpp")==0)) {
739  files.insert(entry.GetName());
740  }
741  }
742 
743 // combining files
744  if ( !m_CombiningFileName.empty() ) {
745  if (is_cpp) {
746  strline = m_CombiningFileName + "__" + "_.cpp";
747  files.insert(strline);
748  strline = m_CombiningFileName + "__" + ".cpp";
749  files.insert(strline);
750  } else {
751  strline = m_CombiningFileName + "__" + ".hpp";
752  files.insert(strline);
753  }
754  }
755 
756 // doxygen header
757  if ( !is_cpp && CClassCode::GetDoxygenComments()
758  && !module_names.empty() ) {
759  CDirEntry entry(GetMainModules().GetModuleSets().front()
760  ->GetSourceFileName());
761  files.insert(entry.GetBase() + "_doxygen.h");
762  }
763 
764 // file list
765  if ( is_cpp && !m_FileListFileName.empty() ) {
767  files.insert(entry.GetName());
768  }
769 
770 // specification dump (somewhat hackishly)
771  if ( const CArgValue& f
772  = CNcbiApplication::Instance()->GetArgs()["fd"] ) {
773  files.insert(f.AsString());
774  }
775 
776  CNcbiOfstream ignoreFile(ignorePath.c_str(), IOS_BASE::out | IOS_BASE::trunc);
777  if (ignoreFile.is_open()) {
778  for( const string& f : files) {
779  if (!f.empty()) {
780  ignoreFile << f << endl;
781  }
782  }
783  }
784  }
785 }
786 
787 void CCodeGenerator::GenerateModuleHPP(const string& path, list<string>& generated) const
788 {
789  set<string> modules;
790  string module_name, current_module, filename, hppDefine;
791  unique_ptr<CDelayedOfstream> out;
792  CNamespace ns;
793 
794  bool isfound = false;
795  do {
796  isfound = false;
797  bool types_found = false;
798  ITERATE ( TOutputFiles, filei, m_Files ) {
799  CFileCode* code = filei->second.get();
800  list<CTypeStrings*> filetypes;
801  code->GetClasses( filetypes );
802  module_name.clear();
803  ITERATE(list<CTypeStrings*>, t, filetypes) {
804  string module = (*t)->GetDoxygenModuleName();
805  if (module_name.empty() || module.size() < module_name.size()) {
806  module_name = module;
807  }
808  }
809  if (current_module.empty()) {
810  if (modules.find(module_name) != modules.end()) {
811  continue;
812  }
813  modules.insert(module_name);
814  current_module = module_name;
815  } else if (current_module != module_name) {
816  continue;
817  }
818  isfound = true;
819  if ( !out.get() || !out->is_open() ) {
820  if (isdigit((unsigned char)current_module[0])) {
821  current_module.insert(current_module.begin(),'x');
822  }
823  filename = Path(path, current_module + "_module.hpp");
824  out.reset(new CDelayedOfstream(filename.c_str()));
825  if (!out->is_open()) {
826  ERR_POST_X(9, Fatal << "Cannot create file: " << filename);
827  return;
828  }
829  generated.push_back(filename);
830  hppDefine = current_module + "_REGISTERMODULECLASSES_HPP";
831  code->WriteCopyright(*out, false) <<
832  "\n"
833  "#ifndef " << hppDefine << "\n"
834  "#define " << hppDefine << "\n"
835  "\n#include <serial/serialbase.hpp>\n\n";
836  ns.Set(code->GetNamespace(), *out, true);
837  *out << '\n';
839  *out << CClassCode::GetExportSpecifier() << '\n';
840  }
841  *out <<
842  "void " << current_module << "_RegisterModuleClasses(void);\n\n";
843  }
844  ITERATE(list<CTypeStrings*>, t, filetypes) {
845  if ((*t)->GetKind() == CTypeStrings::eKindObject) {
846  CClassTypeStrings* classtype = dynamic_cast<CClassTypeStrings*>(*t);
847  if (classtype && classtype->HaveTypeInfo()) {
848  types_found = true;
849  }
850  }
851  }
852  }
853  if (isfound && !types_found) {
854  generated.pop_back();
855  out->Discard();
856  }
857  if (out->is_open()) {
858  ns.Reset(*out);
859  *out <<
860  "\n"
861  "#endif // " << hppDefine << "\n";
862  out->close();
863  if ( !*out )
864  ERR_POST_X(10, Fatal << "Error writing file " << filename);
865  }
866  current_module.erase();
867  } while (isfound);
868 }
869 
870 void CCodeGenerator::GenerateModuleCPP(const string& path, list<string>& generated) const
871 {
872  set<string> modules;
873  string module_name, current_module, filename, hppDefine;
874  unique_ptr<CDelayedOfstream> out;
875  CNcbiOstrstream out_inc;
876  CNcbiOstrstream out_code;
877  CNamespace ns;
878 
879  bool isfound = false;
880  do {
881  isfound = false;
882  bool types_found = false;
883  ITERATE ( TOutputFiles, filei, m_Files ) {
884  CFileCode* code = filei->second.get();
885  list<CTypeStrings*> filetypes;
886  code->GetClasses( filetypes );
887  module_name.clear();
888  ITERATE(list<CTypeStrings*>, t, filetypes) {
889  string module = (*t)->GetDoxygenModuleName();
890  if (module_name.empty() || module.size() < module_name.size()) {
891  module_name = module;
892  }
893  }
894  if (current_module.empty()) {
895  if (modules.find(module_name) != modules.end()) {
896  continue;
897  }
898  modules.insert(module_name);
899  current_module = module_name;
900  } else if (current_module != module_name) {
901  continue;
902  }
903  isfound = true;
904  if ( !out.get() || !out->is_open()) {
905  if (isdigit((unsigned char)current_module[0])) {
906  current_module.insert(current_module.begin(),'x');
907  }
908  filename = Path(path, current_module + "_module.cpp");
909  string module_inc =
910  CDirEntry::ConcatPath( CDirEntry( code->GetUserHPPName() ).GetDir(),
911  current_module + "_module.hpp");
912  out_inc <<
913  "#include " << code->Include(module_inc) << "\n";
914  out.reset(new CDelayedOfstream(filename.c_str()));
915  if (!out->is_open()) {
916  ERR_POST_X(11, Fatal << "Cannot create file: " << filename);
917  return;
918  }
919  generated.push_back(filename);
920  code->WriteCopyright(*out, false);
921  *out << "\n";
922  if (!CFileCode::GetPchHeader().empty()) {
923  *out <<
924  "#include <" << CFileCode::GetPchHeader() << ">\n";
925  }
926  ns.Set(code->GetNamespace(), out_code, false);
927  out_code <<
928  "void " << current_module << "_RegisterModuleClasses(void)\n{\n";
929  }
930  set<string> user_includes;
931  ITERATE(list<CTypeStrings*>, t, filetypes) {
932  if ((*t)->GetKind() == CTypeStrings::eKindObject) {
933  CClassTypeStrings* classtype = dynamic_cast<CClassTypeStrings*>(*t);
934  if (classtype && classtype->HaveTypeInfo()) {
935  types_found = true;
936  string userhpp(code->Include(code->GetUserHPPName()));
937  if (user_includes.find(userhpp) == user_includes.end()) {
938  user_includes.insert(userhpp);
939  out_inc <<
940  "#include " << code->Include(code->GetUserHPPName()) << "\n";
941  }
942  out_code << " "
943  << code->GetClassNamespace(*t).ToString()
944  << classtype->GetClassNameDT() << "::GetTypeInfo();\n";
945  }
946  }
947  }
948  }
949  if (isfound && !types_found) {
950  generated.pop_back();
951  out->Discard();
952  }
953  if (out->is_open()) {
954  out_code << "}\n\n";
955  ns.Reset(out_code);
956  *out << string(CNcbiOstrstreamToString(out_inc))
957  << "\n\n"
958  << string(CNcbiOstrstreamToString(out_code));
959  out_inc.seekp(0);
960  out_code.seekp(0);
961 #ifdef NCBI_SHUN_OSTRSTREAM
962  out_inc.str(kEmptyStr);
963  out_code.str(kEmptyStr);
964 #endif
965  out->close();
966  if ( !*out )
967  ERR_POST_X(12, Fatal << "Error writing file " << filename);
968  }
969  current_module.erase();
970  } while (isfound);
971 }
972 
973 void CCodeGenerator::GenerateClientCode(list<string>& generated)
974 {
975  string clients = m_Config.Get("-", "clients");
976  if (clients.empty()) {
977  // // for compatibility with older specifications
978  // GenerateClientCode("client", false);
979  } else {
980  // explicit name; must be enabled
981  list<string> l;
982  // if multiple items, may have whitespace, commas, or both...
983  NStr::Split(clients, ", \t", l, NStr::fSplit_MergeDelimiters);
984  ITERATE (list<string>, it, l) {
985  if ( !it->empty() ) {
986  GenerateClientCode(*it, true, generated);
987  }
988  }
989  }
990 }
991 
992 void CCodeGenerator::GenerateClientCode(const string& name, bool mandatory, list<string>& generated)
993 {
994  string class_name = m_Config.Get(name, "class");
995  if (class_name.empty()) {
996  if (mandatory) {
997  ERR_POST_X(13, Fatal << "No configuration for mandatory client " + name);
998  }
999  return; // not configured
1000  }
1001  CFileCode code(this,Path(m_FileNamePrefix, name));
1002  CClientPseudoDataType type(*this, name, class_name);
1003  code.UseQuotedForm(m_UseQuotedForm);
1004  code.AddType(&type);
1005  code.GenerateCode();
1006  string filename;
1007  code.GenerateHPP(m_HPPDir, filename);
1008  generated.push_back(filename);
1009  code.GenerateCPP(m_CPPDir, filename);
1010  generated.push_back(filename);
1011  if (code.GenerateUserHPP(m_HPPDir, filename)) {
1012  generated.push_back(filename);
1013  }
1014  if (code.GenerateUserCPP(m_CPPDir, filename)) {
1015  generated.push_back(filename);
1016  }
1017 }
1018 
1020 {
1021  string fileName = type->FileName();
1022  AutoPtr<CFileCode>& file = m_Files[fileName];
1023  if ( !file )
1024  file = new CFileCode(this,fileName);
1025  return file->AddType(type);
1026 }
1027 
1029 {
1030  try {
1031  m_MainFiles.ExternalResolve(type->GetModule()->GetName(),
1032  type->IdName(),
1033  true);
1034  return false;
1035  }
1036  catch ( CNotFoundException& /* ignored */) {
1037  }
1038  return true;
1039 }
1040 
1042 {
1043  if ( type->GetParentType() == 0 ) {
1044  const CWsdlDataType* w = dynamic_cast<const CWsdlDataType*>(type);
1045  if (!w || w->GetWsdlType() == CWsdlDataType::eWsdlEndpoint) {
1046  if ( !AddType(type) ) {
1047  return;
1048  }
1049  }
1050  }
1051 
1052  if ( m_ExcludeRecursion )
1053  return;
1054 
1055  const CUniSequenceDataType* array =
1056  dynamic_cast<const CUniSequenceDataType*>(type);
1057  if ( array != 0 ) {
1058  // we should add element type
1059  CollectTypes(array->GetElementType(), eElement);
1060  return;
1061  }
1062 
1063  const CReferenceDataType* user =
1064  dynamic_cast<const CReferenceDataType*>(type);
1065  if ( user != 0 ) {
1066  // reference to another type
1067  const CDataType* resolved;
1068  try {
1069  resolved = user->Resolve();
1070  }
1071  catch ( CNotFoundException& exc) {
1072  ERR_POST_X(14, Warning <<
1073  "Skipping type: " << user->GetUserTypeName() <<
1074  ": " << exc.what());
1075  return;
1076  }
1077  if ( resolved->Skipped() ) {
1078  ERR_POST_X(15, Warning << "Skipping type: " << user->GetUserTypeName());
1079  return;
1080  }
1081  if ( !Imported(resolved) ) {
1082  CollectTypes(resolved, eReference);
1083  }
1084  return;
1085  }
1086 
1087  const CDataMemberContainerType* cont =
1088  dynamic_cast<const CDataMemberContainerType*>(type);
1089  if ( cont != 0 ) {
1090  // collect member's types
1092  cont->GetMembers() ) {
1093  const CDataType* memberType = mi->get()->GetType();
1094  CollectTypes(memberType, eMember);
1095  }
1096  return;
1097  }
1098 }
1099 
1100 #if 0
1101 void CCodeGenerator::CollectTypes(const CDataType* type, EContext context)
1102 {
1103  const CUniSequenceDataType* array =
1104  dynamic_cast<const CUniSequenceDataType*>(type);
1105  if ( array != 0 ) {
1106  // SET OF or SEQUENCE OF
1107  if ( type->GetParentType() == 0 || context == eChoice ) {
1108  if ( !AddType(type) )
1109  return;
1110  }
1111  if ( m_ExcludeRecursion )
1112  return;
1113  // we should add element type
1114  CollectTypes(array->GetElementType(), eElement);
1115  return;
1116  }
1117 
1118  const CReferenceDataType* user =
1119  dynamic_cast<const CReferenceDataType*>(type);
1120  if ( user != 0 ) {
1121  // reference to another type
1122  const CDataType* resolved;
1123  try {
1124  resolved = user->Resolve();
1125  }
1126  catch ( CNotFoundException& exc) {
1127  ERR_POST_X(16, Warning <<
1128  "Skipping type: " << user->GetUserTypeName() <<
1129  ": " << exc.what());
1130  return;
1131  }
1132  if ( resolved->Skipped() ) {
1133  ERR_POST_X(17, Warning << "Skipping type: " << user->GetUserTypeName());
1134  return;
1135  }
1136  if ( context == eChoice ) {
1137  // in choice
1138  if ( resolved->InheritFromType() != user->GetParentType() ||
1139  dynamic_cast<const CEnumDataType*>(resolved) != 0 ) {
1140  // add intermediate class
1141  AddType(user);
1142  }
1143  }
1144  else if ( type->GetParentType() == 0 ) {
1145  // alias declaration
1146  // generate empty class
1147  AddType(user);
1148  }
1149  if ( !Imported(resolved) ) {
1150  CollectTypes(resolved, eReference);
1151  }
1152  return;
1153  }
1154 
1155  if ( dynamic_cast<const CStaticDataType*>(type) != 0 ) {
1156  // STD type
1157  if ( type->GetParentType() == 0 || context == eChoice ) {
1158  AddType(type);
1159  }
1160  return;
1161  }
1162 
1163  if ( dynamic_cast<const CEnumDataType*>(type) != 0 ) {
1164  // ENUMERATED type
1165  if ( type->GetParentType() == 0 || context == eChoice ) {
1166  AddType(type);
1167  }
1168  return;
1169  }
1170 
1171  if ( type->GetParentType() == 0 || context == eChoice ) {
1172  if ( type->Skipped() ) {
1173  ERR_POST_X(18, Warning << "Skipping type: " << type->IdName());
1174  return;
1175  }
1176  }
1177 
1178  const CChoiceDataType* choice =
1179  dynamic_cast<const CChoiceDataType*>(type);
1180  if ( choice != 0 ) {
1181  if ( !AddType(type) )
1182  return;
1183 
1184  if ( m_ExcludeRecursion )
1185  return;
1186 
1187  // collect member's types
1189  choice->GetMembers() ) {
1190  const CDataType* memberType = mi->get()->GetType();
1191  CollectTypes(memberType, eMember); // eChoice
1192  }
1193  }
1194 
1195  const CDataMemberContainerType* cont =
1196  dynamic_cast<const CDataMemberContainerType*>(type);
1197  if ( cont != 0 ) {
1198  if ( !AddType(type) )
1199  return;
1200 
1201  if ( m_ExcludeRecursion )
1202  return;
1203 
1204  // collect member's types
1206  cont->GetMembers() ) {
1207  const CDataType* memberType = mi->get()->GetType();
1208  CollectTypes(memberType, eMember);
1209  }
1210  return;
1211  }
1212  if ( !AddType(type) )
1213  return;
1214 }
1215 #endif
1216 
1218 {
1219  ITERATE( CFileSet::TModuleSets, fs, GetMainModules().GetModuleSets()) {
1220  ITERATE(CFileModules::TModules, fm, (*fs)->GetModules()) {
1221  CDataTypeModule* head = const_cast<CDataTypeModule*>(fm->get());
1222  head->AddImportRef( head->GetName());
1224  }
1225  }
1226 }
1227 
1229 {
1230  if (ref) {
1232  const string& s = (*i)->moduleName;
1233  if (head.AddImportRef(s)) {
1235  }
1236  }
1237  }
1238 }
1239 
1240 const CDataTypeModule* CCodeGenerator::FindModuleByName(const string& name) const
1241 {
1242  ITERATE( CFileSet::TModuleSets, mm, GetMainModules().GetModuleSets()) {
1243  ITERATE(CFileModules::TModules, fm, (*mm)->GetModules()) {
1244  if ((*fm)->GetName() == name) {
1245  return fm->get();
1246  }
1247  }
1248  }
1249  ITERATE( CFileSet::TModuleSets, mi, GetImportModules().GetModuleSets()) {
1250  ITERATE(CFileModules::TModules, fm, (*mi)->GetModules()) {
1251  if ((*fm)->GetName() == name) {
1252  return fm->get();
1253  }
1254  }
1255  }
1256  ERR_POST_X(19, Error << "cannot find module " << name);
1257  return 0;
1258 }
1259 
1260 bool CCodeGenerator::GetOpt(const string& opt, string* value)
1261 {
1262  string result;
1263  string key("-");
1264  string xopt = key + opt;
1265  if (m_Config.HasEntry(key, xopt)) {
1266  result = m_Config.Get(key, xopt);
1267  if (value) {
1268  *value = result;
1269  }
1270  return (result != key);
1271  }
1272  const CArgs& args = CNcbiApplication::Instance()->GetArgs();
1273  const CArgValue& argv = args[opt];
1274  if (argv.HasValue()) {
1275  if (value) {
1276  *value = argv.AsString();
1277  }
1278  return true;
1279  }
1280  return false;
1281 }
1282 
1283 
CArgValue –.
Definition: ncbiargs.hpp:184
CArgs –.
Definition: ncbiargs.hpp:379
static const string & GetExportSpecifier(void)
Definition: code.cpp:88
static const string & GetDoxygenGroup(void)
Definition: code.cpp:107
static bool GetDoxygenComments(void)
Definition: code.cpp:97
bool HaveTypeInfo(void) const
Definition: classstr.hpp:142
const string & GetClassNameDT(void) const
Definition: classstr.hpp:99
void UseQuotedForm(bool use)
Definition: generate.cpp:82
string m_DefFile
Definition: generate.hpp:214
string m_HPPDir
Definition: generate.hpp:205
string m_FileListFileName
Definition: generate.hpp:203
void CheckFileNames(void)
Definition: generate.cpp:330
bool m_ExcludeRecursion
Definition: generate.hpp:202
string m_DoxygenGroupDescription
Definition: generate.hpp:213
void ResolveImportRefs(void)
Definition: generate.cpp:1217
void SetFileNamePrefix(const string &prefix)
Definition: generate.cpp:92
void GenerateModuleHPP(const string &path, list< string > &generated) const
Definition: generate.cpp:787
string m_CPPDir
Definition: generate.hpp:206
void LoadConfig(CNcbiIstream &in)
Definition: generate.cpp:129
CFileSet & GetMainModules(void)
Definition: generate.hpp:94
string m_CombiningFileName
Definition: generate.hpp:204
CNamespace m_DefaultNamespace
Definition: generate.hpp:209
void GenerateFileList(const list< string > &generated, const list< string > &untouched, list< string > &allGeneratedHpp, list< string > &allGeneratedCpp, list< string > &allSkippedHpp, list< string > &allSkippedCpp)
Definition: generate.cpp:454
CDataType * ExternalResolve(const string &module, const string &type, bool allowInternal=false) const
Definition: generate.cpp:173
const string & GetRootDir(void) const
Definition: generate.hpp:118
static void GetTypes(TTypeNames &typeNames, const string &name)
Definition: generate.cpp:251
CMemoryRegistry m_Config
Definition: generate.hpp:198
virtual string GetFileNamePrefix(void) const override
Definition: generate.cpp:77
void GenerateDoxygenGroupDescription(map< string, pair< string, string > > &module_names)
Definition: generate.cpp:407
bool Check(void) const
Definition: generate.cpp:263
EFileNamePrefixSource m_FileNamePrefixSource
Definition: generate.hpp:208
void GenerateClientCode(list< string > &generated)
Definition: generate.cpp:973
virtual const CMemoryRegistry & GetConfig(void) const override
Definition: generate.cpp:72
void GenerateCode(void)
Definition: generate.cpp:344
void GenerateCvsignore(const string &outdir_cpp, const string &outdir_hpp, const list< string > &generated, map< string, pair< string, string > > &module_names)
Definition: generate.cpp:686
CCodeGenerator(void)
Definition: generate.cpp:59
void AddConfigLine(const string &s)
Definition: generate.cpp:160
CDataType * ResolveInAnyModule(const string &type, bool allowInternal=false) const
Definition: generate.cpp:192
bool m_CreateCvsignore
Definition: generate.hpp:211
TTypeNames m_GenerateTypes
Definition: generate.hpp:201
void SetFileNamePrefixSource(EFileNamePrefixSource source)
Definition: generate.cpp:102
void ExcludeTypes(const string &types)
Definition: generate.cpp:269
~CCodeGenerator(void)
Definition: generate.cpp:68
CFileSet m_MainFiles
Definition: generate.hpp:199
void CollectTypes(const CDataType *type, EContext context)
Definition: generate.cpp:1041
bool GetOpt(const string &opt, string *value=0)
Definition: generate.cpp:1260
string m_FileNamePrefix
Definition: generate.hpp:207
void SetDefaultNamespace(const string &ns)
Definition: generate.cpp:119
virtual const CNamespace & GetNamespace(void) const override
Definition: generate.cpp:114
virtual CDataType * InternalResolve(const string &moduleName, const string &typeName) const override
Definition: generate.cpp:108
bool Imported(const CDataType *type) const
Definition: generate.cpp:1028
void UndoGenerateCode(void)
Definition: generate.cpp:292
bool IsGitRepository(const string &dir) const
Definition: generate.cpp:667
void ResetDefaultNamespace(void)
Definition: generate.cpp:124
TOutputFiles m_Files
Definition: generate.hpp:217
void GenerateModuleCPP(const string &path, list< string > &generated) const
Definition: generate.cpp:870
void CreateCvsignore(bool create)
Definition: generate.cpp:87
bool m_UseQuotedForm
Definition: generate.hpp:210
CDataType * ResolveMain(const string &fullName) const
Definition: generate.cpp:210
CFileSet m_ImportFiles
Definition: generate.hpp:200
CFileSet & GetImportModules(void)
Definition: generate.hpp:102
bool AddType(const CDataType *type)
Definition: generate.cpp:1019
string m_DoxygenIngroup
Definition: generate.hpp:212
void IncludeAllMainTypes(void)
Definition: generate.cpp:234
const CDataTypeModule * FindModuleByName(const string &name) const
Definition: generate.cpp:1240
void IncludeTypes(const string &types)
Definition: generate.cpp:279
virtual EFileNamePrefixSource GetFileNamePrefixSource(void) const override
Definition: generate.cpp:97
const string & ResolveFileName(const string &name) const
Definition: generate.cpp:225
void GenerateCombiningFile(const list< string > &module_inc, const list< string > &module_src, list< string > &allHpp, list< string > &allCpp)
Definition: generate.cpp:600
const TMembers & GetMembers(void) const
Definition: blocktype.hpp:155
list< AutoPtr< CDataMember > > TMembers
Definition: blocktype.hpp:137
list< AutoPtr< Import > > TImports
Definition: module.hpp:68
const TImports & GetImports(void) const
Definition: module.hpp:127
const TDefinitions & GetDefinitions(void) const
Definition: module.hpp:107
const string & GetName(void) const
Definition: module.hpp:103
list< pair< string, AutoPtr< CDataType > > > TDefinitions
Definition: module.hpp:70
const CDataType * InheritFromType(void) const
Definition: type.cpp:695
const CDataType * GetParentType(void) const
Definition: type.hpp:164
bool Skipped(void) const
Definition: type.cpp:525
CDirEntry –.
Definition: ncbifile.hpp:262
static const string & GetPchHeader(void)
Definition: filecode.hpp:129
static CNcbiOstream & WriteCopyrightHeader(CNcbiOstream &out)
Definition: filecode.cpp:250
list< AutoPtr< CDataTypeModule > > TModules
Definition: moduleset.hpp:55
const TModuleSets & GetModuleSets(void) const
Definition: moduleset.hpp:119
list< AutoPtr< CFileModules > > TModuleSets
Definition: moduleset.hpp:115
CDataType * ResolveInAnyModule(const string &fullName, bool allowInternal=false) const
Definition: moduleset.cpp:438
bool Check(void) const
Definition: moduleset.cpp:455
bool CheckNames(void) const
Definition: moduleset.cpp:465
CDataType * ExternalResolve(const string &moduleName, const string &typeName, bool allowInternal=false) const
Definition: moduleset.cpp:421
CFile –.
Definition: ncbifile.hpp:1604
CMemoryRegistry –.
Definition: ncbireg.hpp:584
virtual const string & GetSourceFileName(void) const
Definition: mcontainer.cpp:65
void SetModuleContainer(const CModuleContainer *parent)
Definition: mcontainer.cpp:48
void Set(const CNamespace &ns, CNcbiOstream &out, bool mainHeader=true)
Definition: namespace.cpp:89
void Reset(void)
Definition: namespace.hpp:61
static CNcbiApplication * Instance(void)
Singleton method.
Definition: ncbiapp.cpp:264
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
virtual const CDataType * Resolve(void) const override
Definition: reftype.cpp:345
const string & GetUserTypeName(void) const
Definition: reftype.hpp:68
EType GetWsdlType(void) const
Definition: blocktype.hpp:227
const_iterator end() const
Definition: map.hpp:152
const_iterator find(const key_type &key) const
Definition: map.hpp:153
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator find(const key_type &key) const
Definition: set.hpp:137
void erase(iterator pos)
Definition: set.hpp:151
const_iterator end() const
Definition: set.hpp:136
#define head
Definition: ct_nlmzip_i.h:138
std::ofstream out("events_result.xml")
main entry point for tests
string BaseName(const string &path)
Definition: fileutil.cpp:262
string Path(const string &dir, const string &file)
Definition: fileutil.cpp:243
string GetStdPath(const string &path)
Definition: fileutil.cpp:291
string MakeAbsolutePath(const string &path)
Definition: fileutil.cpp:233
static const struct name_t names[]
#define false
Definition: bool.h:36
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
Definition: dlist.tmpl.h:56
static int trunc
Definition: array_out.c:8
static int type
Definition: getdata.c:31
static const struct type types[]
Definition: type.c:22
static char tmp[3200]
Definition: utf8.c:42
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
Definition: ncbiapp.cpp:305
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
virtual const string & AsString(void) const =0
Get the argument's string value.
virtual bool HasValue(void) const =0
Check if argument holds a value.
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#define _TRACE(message)
Definition: ncbidbg.hpp:122
#define _DEBUG_ARG(arg)
Definition: ncbidbg.hpp:134
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
#define NCBI_RETHROW_SAME(prev_exception, message)
Generic macro to re-throw the same exception.
Definition: ncbiexpt.hpp:749
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
void Fatal(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1209
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
string GetDir(EIfEmptyPath mode=eIfEmptyPath_Current) const
Get the directory component for this directory entry.
Definition: ncbifile.cpp:475
string GetBase(void) const
Get the base entry name without extension.
Definition: ncbifile.hpp:3924
virtual bool Remove(TRemoveFlags flags=eRecursive) const
Remove a directory entry.
Definition: ncbifile.cpp:2595
static string ConvertToOSPath(const string &path)
Convert "path" on any OS to the current OS-dependent path.
Definition: ncbifile.cpp:745
static string ConcatPath(const string &first, const string &second)
Concatenate two parts of the path for the current OS.
Definition: ncbifile.cpp:776
void Reset(const string &path)
Reset path string.
Definition: ncbifile.cpp:298
string GetName(void) const
Get the base entry name with extension (if any).
Definition: ncbifile.hpp:3916
const string & GetPath(void) const
Get entry path.
Definition: ncbifile.hpp:3910
string GetExt(void) const
Get extension name.
Definition: ncbifile.hpp:3932
virtual bool Exists(void) const
Check existence of file.
Definition: ncbifile.hpp:4038
@ eIfEmptyPath_Empty
Return empty string.
Definition: ncbifile.hpp:330
virtual const string & Get(const string &section, const string &name, TFlags flags=0) const
Get the parameter value.
Definition: ncbireg.cpp:262
virtual bool HasEntry(const string &section, const string &name=kEmptyStr, TFlags flags=0) const
Definition: ncbireg.cpp:290
IRWRegistry * Read(CNcbiIstream &is, TFlags flags=0, const string &path=kEmptyStr)
Read and parse the stream "is", and merge its content with current Registry entries.
Definition: ncbireg.cpp:605
bool Set(const string &section, const string &name, const string &value, TFlags flags=0, const string &comment=kEmptyStr)
Set the configuration parameter value.
Definition: ncbireg.cpp:826
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
CNcbiIstream & NcbiGetlineEOL(CNcbiIstream &is, string &str, string::size_type *count=NULL)
Read from "is" to "str" the next line (taking into account platform specifics of End-of-Line)
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
Definition: ncbistre.hpp:500
#define NcbiCin
Definition: ncbistre.hpp:542
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
Definition: ncbistre.hpp:439
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
#define kEmptyStr
Definition: ncbistr.hpp:123
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
Definition: ncbistr.cpp:219
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.
Definition: ncbistr.cpp:3461
#define NPOS
Definition: ncbistr.hpp:133
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3314
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3405
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string.
Definition: ncbistr.cpp:3186
@ fSplit_Truncate
Definition: ncbistr.hpp:2501
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
Definition: ncbistr.hpp:2498
Definition of all error codes used in serial libraries (xser.lib, xcser.lib).
FILE * file
int i
EFileNamePrefixSource
Definition: mcontainer.hpp:45
@ eFileName_FromNone
Definition: mcontainer.hpp:46
constexpr auto front(list< Head, As... >, T=T()) noexcept -> Head
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
const CharType(& source)[N]
Definition: pointer.h:1149
EIPRangeType t
Definition: ncbi_localip.c:101
#define GetArgs
Avoid preprocessor name clash with the NCBI C Toolkit.
Definition: ncbiapp_api.hpp:54
int isdigit(Uchar c)
Definition: ncbictype.hpp:64
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
bool eq(T x_, T y_, T round_)
Definition: njn_approx.hpp:79
std::istream & in(std::istream &in_, double &x_)
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
static const char * suffix[]
Definition: pcregrep.c:408
static const char * prefix[]
Definition: pcregrep.c:405
Definition: inftrees.h:24
bool operator()(const string &s1, const string &s2) const
Definition: generate.cpp:286
Definition: type.c:6
else result
Definition: token2.c:20
static CS_CONTEXT * context
Definition: will_convert.c:21
#define local
Definition: zutil.h:33
Modified on Sat May 18 11:42:09 2024 by modify_doxy.py rev. 669887