Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

DocumentGenerator Class Reference

#include <cmt_generators.h>

Inheritance diagram for DocumentGenerator:

Inheritance graph
[legend]
Collaboration diagram for DocumentGenerator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DocumentGenerator ()
void build (const cmt_string &package, const Constituent &constituent)

Private Member Functions

void reset ()
bool analyze_file (const cmt_string &file, const cmt_string &constituent_name, const cmt_string &output_suffix)

Private Attributes

FragmentHandle document_header_fragment

Constructor & Destructor Documentation

DocumentGenerator::DocumentGenerator  ) 
 

Definition at line 836 of file cmt_generators.cxx.

References document_header_fragment, and FragmentHandle::set().

00837 {
00838   document_header_fragment.set ("document_header");
00839 }


Member Function Documentation

bool DocumentGenerator::analyze_file const cmt_string file,
const cmt_string constituent_name,
const cmt_string output_suffix
[private]
 

Definition at line 1097 of file cmt_generators.cxx.

References cmt_vector< SourceFile >::add(), CmtSystem::basename(), CmtSystem::dirname(), CmtSystem::file_separator(), CmtGenerator::filter_path(), CmtSystem::get_suffix(), SourceFile::set(), CmtSystem::test_directory(), and CmtSystem::test_file().

Referenced by build().

01100 {
01101   static cmt_string output_dir;
01102   static cmt_string suffix;
01103   static cmt_string name;
01104   static cmt_string obj;
01105 
01106   if (!CmtSystem::test_file (file) && !CmtSystem::test_directory (file))
01107     {
01108       cerr << "#CMT> Warning: Source file " << file << " not found" << endl;
01109     }
01110 
01111   CmtSystem::dirname (file, output_dir);
01112   output_dir += CmtSystem::file_separator ();
01113 
01114   filter_path (output_dir);
01115 
01116   CmtSystem::get_suffix (file, suffix);
01117   CmtSystem::basename (file, suffix, name);
01118 
01119   //obj = output_dir;
01120   obj = "$(";
01121   obj += constituent_name;
01122   obj += "_output)";
01123   obj += name;
01124   obj += output_suffix;
01125 
01126   SourceFile& source = m_source_files.add ();
01127   source.set (file, Language::null (), obj);
01128 
01129   return (true);
01130 }

void DocumentGenerator::build const cmt_string package,
const Constituent constituent
 

Definition at line 849 of file cmt_generators.cxx.

References analyze_file(), CmtSystem::basename(), cmt_string::c_str(), CmtSystem::cmt_string_vector, CmtSystem::compress_path(), FragmentHandle::copy(), CmtSystem::dirname(), document_header_fragment, Constituent::exclude_exprs, CmtSystem::file_separator(), CmtGenerator::fill_outputs(), CmtGenerator::filter_path(), Constituent::generator, CmtGenerator::get_all_files(), CmtSystem::get_dot_suffix(), CmtSystem::get_suffix(), Constituent::has_target_tag, FragmentHandle::header(), Constituent::includes, Constituent::modules, SourceFile::name(), Constituent::name, FragmentHandle::name(), FragmentHandle::need_dependencies(), CmtSystem::now(), CmtGenerator::prepare_output(), CmtGenerator::prepare_use_context(), reset(), Constituent::select_exprs, CmtGenerator::set_full_name(), cmt_vector< SourceFile >::size(), cmt_vector< T >::size(), FragmentHandle::suffix(), CmtGenerator::terminate(), CmtSystem::test_directory(), CmtSystem::test_file(), FragmentHandle::trailer(), CmtSystem::user(), Variable::value, and Constituent::variables.

Referenced by Generator::build_constituent_makefile().

00851 {
00852   static cmt_string names;
00853   static cmt_string output_dir;
00854   static cmt_string name;
00855   static cmt_string full_name;
00856   static cmt_string compressed_name;
00857   static cmt_string suffix;
00858   static cmt_string output_suffix;
00859   static cmt_string fragment_suffix;
00860 
00861   reset ();
00862 
00863   if (!prepare_output (package, constituent)) return;
00864 
00865   is_library = false;
00866   is_application = false;
00867   m_GENERATOR = constituent.generator;
00868   m_TITLE = "Document";
00869 
00870   int i;
00871 
00872   cout << m_TITLE << " " << m_CONSTITUENT << endl;
00873 
00874   //
00875   // Prepare the include paths.
00876   //
00877 
00878   const CmtSystem::cmt_string_vector& includes = constituent.includes;
00879 
00880   for (i = 0; i < includes.size (); i++)
00881     {
00882       const cmt_string& subdir = includes[i];
00883 
00884       m_PACKINCLUDES += " -I";
00885       m_PACKINCLUDES += subdir;
00886     }
00887 
00888   //
00889   // Get the fragment associated with the document style
00890   //
00891 
00892   FragmentHandle fragment (m_GENERATOR);
00893 
00894   fragment_suffix = fragment.suffix ();
00895 
00896   output_suffix = ".";
00897 
00898   if (fragment_suffix == "")
00899     {
00900       output_suffix += fragment.name ();
00901     }
00902   else
00903     {
00904       output_suffix += fragment_suffix;
00905     }
00906 
00907   //
00908   // Scan the sources.
00909   //
00910 
00911   const CmtSystem::cmt_string_vector& sources = constituent.modules;
00912   const cmt_vector<cmt_regexp>& excludes = constituent.exclude_exprs;
00913   const cmt_vector<cmt_regexp>& selects = constituent.select_exprs;
00914 
00915   m_LINE = "";
00916 
00917   for (i = 0; i < sources.size (); i++)
00918     {
00919       cmt_string& file = sources[i];
00920 
00921       set_full_name (full_name, file);
00922       if (full_name == "") continue;
00923 
00924       CmtSystem::compress_path (full_name, compressed_name);
00925       full_name = compressed_name;
00926 
00927       static CmtSystem::cmt_string_vector files;
00928 
00929       int count = get_all_files (full_name, excludes, selects, files);
00930 
00931       filter_path (full_name);
00932 
00933       if (count > 0)
00934         {
00935           m_LINE += full_name;
00936           m_LINE += " ";
00937         }
00938 
00939       for (int j = 0; j < files.size (); j++)
00940         {
00941           const cmt_string& name = files[j];
00942 
00943           if (name != "") 
00944             {
00945               analyze_file (name, constituent.name, output_suffix);
00946             }
00947         }
00948     }
00949 
00950   fill_outputs ();
00951 
00952   prepare_use_context ();
00953 
00954   m_DATE = CmtSystem::now ();
00955   m_USER = CmtSystem::user ();
00956   m_PACKAGE = package;
00957 
00958   if (constituent.has_target_tag)
00959     {
00960       m_HASTARGETTAG = "has_target_tag";
00961     }
00962   else
00963     {
00964       m_HASTARGETTAG = "has_no_target_tag";
00965     }
00966 
00967   make_header_fragment.copy (m_output_file, constituent.variables, 7,
00968                              &m_TITLE, 
00969                              &m_CONSTITUENT,
00970                              &m_CONSTITUENTSUFFIX,
00971                              &m_USER,
00972                              &m_DATE,
00973                              &m_PACKAGE,
00974                              &m_HASTARGETTAG);
00975 
00976   const cmt_string& header = fragment.header ();
00977 
00978   //
00979   // If the document type specifies a header, use it . 
00980   // otherwise, use the default document header fragment.
00981   //
00982   if (header != "")
00983     {
00984       FragmentHandle header_fragment (header);
00985       header_fragment.copy (m_output_file, constituent.variables, 3, 
00986                             &m_CONSTITUENT,
00987                             &m_CONSTITUENTSUFFIX,
00988                             &m_OBJS);
00989     }
00990   else
00991     {
00992       document_header_fragment.copy (m_output_file, constituent.variables, 3, 
00993                                      &m_CONSTITUENT,
00994                                      &m_CONSTITUENTSUFFIX,
00995                                      &m_OBJS);
00996     }
00997 
00998   if (fragment.need_dependencies ())
00999     {
01000       dependencies_fragment.copy (m_output_file, constituent.variables, 3, 
01001                                   &m_CONSTITUENT,
01002                                   &m_CONSTITUENTSUFFIX,
01003                                   &m_LINE);
01004     }
01005   else
01006     {
01007       for (i = 0; i < sources.size (); i++)
01008         {
01009           cmt_string& file = sources[i];
01010           
01011           set_full_name (full_name, file);
01012           if (full_name == "") continue;
01013           
01014           CmtSystem::compress_path (full_name, compressed_name);
01015           full_name = compressed_name;
01016 
01017           static CmtSystem::cmt_string_vector files;
01018           
01019           get_all_files (full_name, excludes, selects, files);
01020           
01021           for (int j = 0; j < files.size (); j++)
01022             {
01023               const cmt_string& name = files[j];
01024               
01025               if (name != "") 
01026                 {
01027                   static cmt_string s;
01028                   static cmt_string n;
01029                   
01030                   CmtSystem::get_dot_suffix (name, s);
01031                   CmtSystem::basename (name, s, n);
01032                   CmtSystem::get_suffix (name, s);
01033                   
01034                   fprintf (m_output_file, "%s_%s_dependencies = %s\n",
01035                            n.c_str (),
01036                            s.c_str (),
01037                            name.c_str ());
01038                 }
01039             }
01040         }
01041     }
01042   
01043   m_SUFFIX = fragment_suffix;
01044   for (i = 0; i < m_source_files.size (); i++)
01045     {
01046       SourceFile& file = m_source_files[i];
01047       const cmt_string& file_name = file.name ();
01048       m_FULLNAME = file_name;
01049       CmtSystem::get_dot_suffix (file_name, suffix);
01050       CmtSystem::basename (file_name, suffix, m_NAME.value);
01051       CmtSystem::dirname (file_name, m_FILEPATH.value);
01052       if (m_FILEPATH.value != "") m_FILEPATH.value += CmtSystem::file_separator ();
01053       filter_path (m_FILEPATH.value);
01054       CmtSystem::basename (file_name, m_FILENAME.value);
01055       CmtSystem::get_dot_suffix (m_FILENAME.value, m_FILESUFFIX.value);
01056 
01057       if (!CmtSystem::test_file (file_name) && !CmtSystem::test_directory (file_name))
01058         {
01059           cerr << "#CMT> Warning: Source file " << file_name << " not found" << endl;
01060         }
01061 
01062       filter_path (m_FULLNAME.value);
01063 
01064       fragment.copy (m_output_file, constituent.variables, 8,
01065                      &m_FILEPATH,
01066                      &m_SUFFIX,
01067                      &m_CONSTITUENT,
01068                      &m_CONSTITUENTSUFFIX,
01069                      &m_FILENAME,
01070                      &m_NAME,
01071                      &m_FULLNAME,
01072                      &m_FILESUFFIX);
01073     }
01074 
01075   const cmt_string& trailer = fragment.trailer ();
01076   if (trailer != "")
01077     {
01078       FragmentHandle trailer_fragment (trailer);
01079       trailer_fragment.copy (m_output_file, constituent.variables, 3, 
01080                              &m_CONSTITUENT,
01081                              &m_CONSTITUENTSUFFIX,
01082                              &m_OBJS);
01083     }
01084 
01085   //
01086   //  Generate package cleanup operations.
01087   //
01088 
01089   cleanup_header_fragment.copy (m_output_file, constituent.variables, 2, 
01090                                 &m_CONSTITUENT,
01091                                 &m_CONSTITUENTSUFFIX);
01092 
01093   terminate ();
01094 }

void DocumentGenerator::reset  )  [private]
 

Reimplemented from AnyDocumentGenerator.

Definition at line 842 of file cmt_generators.cxx.

References document_header_fragment, FragmentHandle::reset(), and AnyDocumentGenerator::reset().

Referenced by build().

00843 {
00844   AnyDocumentGenerator::reset ();
00845   document_header_fragment.reset ();
00846 }


Member Data Documentation

FragmentHandle DocumentGenerator::document_header_fragment [private]
 

Definition at line 44 of file cmt_generators.h.

Referenced by build(), DocumentGenerator(), and reset().


The documentation for this class was generated from the following files:
Generated on Mon May 2 10:25:37 2005 for CMT by doxygen 1.3.5