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

Language Class Reference

#include <cmt_language.h>

Collaboration diagram for Language:

Collaboration graph
[legend]
List of all members.

Public Types

typedef cmt_vector< LanguageLanguageVector

Public Member Functions

 Language ()
 ~Language ()
void clear ()
void show ()
void setup_fragments ()
bool operator== (const cmt_string &name) const
bool operator== (const Language &other) const
bool operator!= (const Language &other) const

Static Public Member Functions

void action (const CmtSystem::cmt_string_vector &words)
Languagefind (const cmt_string &name)
Languagefind_with_suffix (const cmt_string &suffix)
Languageadd (const cmt_string &name)
void show (const cmt_string &name)
void show_all ()
void show_names ()
void setup_all_fragments ()
void clear_all ()
LanguageVectorlanguages ()
Languagenull ()

Public Attributes

cmt_string m_name
cmt_string fragment_name
cmt_string linker
cmt_string output_suffix
bool prototypes
cmt_string preprocessor_command
CmtSystem::cmt_string_vector suffixes
CmtSystem::cmt_string_vector extra_output_suffixes
FragmentHandle application
FragmentHandle library

Member Typedef Documentation

typedef cmt_vector<Language> Language::LanguageVector
 

Definition at line 16 of file cmt_language.h.

Referenced by add(), clear_all(), find(), find_with_suffix(), languages(), Database::languages(), setup_all_fragments(), show_all(), and show_names().


Constructor & Destructor Documentation

Language::Language  ) 
 

Definition at line 251 of file cmt_language.cxx.

References clear().

00253 {
00254   clear ();
00255 }

Language::~Language  ) 
 

Definition at line 258 of file cmt_language.cxx.

00260 {
00261 }


Member Function Documentation

void Language::action const CmtSystem::cmt_string_vector words  )  [static]
 

Definition at line 139 of file cmt_language.cxx.

References cmt_vector< T >::add(), add(), CmtSystem::cmt_string_vector, cmt_string::erase(), extra_output_suffixes, fragment_name, linker, output_suffix, preprocessor_command, prototypes, cmt_string::substr(), and suffixes.

Referenced by KwdLanguage::action().

00141 {
00142   cmt_string name;
00143 
00144   int i = 1;
00145 
00146   name = words[i];
00147   if (name == "") return;
00148   i++;
00149 
00150   Language& language = add (name);
00151 
00152   for (;i < words.size (); i++)
00153     {
00154       cmt_string& w = words[i];
00155       if (w == "") break;
00156 
00157       if (w.substr (0, 8) == "-suffix=")
00158         {
00159           cmt_string& suffix = language.suffixes.add ();
00160 
00161           suffix.erase (0);
00162           w.substr (8, suffix);
00163         }
00164       else if (w.substr (0, 8) == "-linker=")
00165         {
00166           w.substr (8, language.linker);
00167         }
00168       else if (w.substr (0, 11) == "-prototypes")
00169         {
00170           language.prototypes = true;
00171         }
00172       else if (w.substr (0, 22) == "-preprocessor_command=")
00173         {
00174           w.substr (22, language.preprocessor_command);
00175         }
00176       else if (w.substr (0, 10) == "-fragment=")
00177         {
00178           w.substr (10, language.fragment_name);
00179         }
00180       else if (w.substr (0, 15) == "-output_suffix=")
00181         {
00182           w.substr (15, language.output_suffix);
00183         }
00184       else if (w.substr (0, 21) == "-extra_output_suffix=")
00185         {
00186           cmt_string& suffix = language.extra_output_suffixes.add ();
00187 
00188           suffix.erase (0);
00189           w.substr (21, suffix);
00190         }
00191     }
00192 }

Language & Language::add const cmt_string name  )  [static]
 

Definition at line 195 of file cmt_language.cxx.

References cmt_vector< T >::add(), clear(), find(), fragment_name, languages(), LanguageVector, m_name, and null().

Referenced by action().

00197 {
00198   static LanguageVector& Languages = languages ();
00199 
00200   if (name == "") return (null ());
00201 
00202   {
00203     Language& language = find (name);
00204     if (language != null ()) return (language);
00205   }
00206 
00207   Language& language = Languages.add ();
00208 
00209   language.clear ();
00210   language.m_name = name;
00211   language.fragment_name = name;
00212 
00213   return (language);
00214 }

void Language::clear  ) 
 

Definition at line 264 of file cmt_language.cxx.

References cmt_vector< T >::clear(), extra_output_suffixes, fragment_name, linker, m_name, output_suffix, preprocessor_command, prototypes, and suffixes.

Referenced by add(), clear_all(), and Language().

00266 {
00267   m_name = "";
00268   linker = "none";
00269   prototypes = false;
00270   preprocessor_command = "-I";
00271   fragment_name = "";
00272   output_suffix = "";
00273   suffixes.clear ();
00274   extra_output_suffixes.clear ();
00275 }

void Language::clear_all  )  [static]
 

Definition at line 218 of file cmt_language.cxx.

References cmt_vector< T >::clear(), clear(), languages(), LanguageVector, and cmt_vector< T >::size().

Referenced by Database::clear().

00220 {
00221   static LanguageVector& Languages = languages ();
00222 
00223   for (int i = 0; i < Languages.size (); i++)
00224     {
00225       Language& c = Languages[i];
00226       c.clear ();
00227     }
00228   Languages.clear ();
00229 }

Language & Language::find const cmt_string name  )  [static]
 

Definition at line 85 of file cmt_language.cxx.

References languages(), LanguageVector, m_name, null(), and cmt_vector< T >::size().

Referenced by add(), and show().

00087 {
00088   static LanguageVector& Languages = languages ();
00089 
00090   int language_index;
00091 
00092   if (Languages.size () == 0) return (null ());
00093 
00094   for (language_index = 0;
00095        language_index < Languages.size ();
00096        language_index++)
00097     {
00098       Language& language = Languages[language_index];
00099 
00100       if (language.m_name == name)
00101         {
00102           return (language);
00103         }
00104     }
00105 
00106   return (null ());
00107 }

Language & Language::find_with_suffix const cmt_string suffix  )  [static]
 

Definition at line 110 of file cmt_language.cxx.

References languages(), LanguageVector, null(), cmt_vector< T >::size(), and suffixes.

Referenced by LibraryGenerator::analyze_file().

00112 {
00113   static LanguageVector& Languages = languages ();
00114 
00115   int language_index;
00116 
00117   if (Languages.size () == 0) return (null ());
00118 
00119   for (language_index = 0;
00120        language_index < Languages.size ();
00121        language_index++)
00122     {
00123       Language& language = Languages[language_index];
00124 
00125       for (int suffix_index = 0;
00126            suffix_index < language.suffixes.size ();
00127            suffix_index++)
00128         {
00129           cmt_string& s = language.suffixes[suffix_index];
00130 
00131           if (s == suffix) return (language);
00132         }
00133     }
00134 
00135   return (null ());
00136 }

Language::LanguageVector & Language::languages  )  [static]
 

Definition at line 232 of file cmt_language.cxx.

References Database::instance(), Database::languages(), and LanguageVector.

Referenced by add(), clear_all(), find(), find_with_suffix(), setup_all_fragments(), show_all(), and show_names().

00234 {
00235   static Database& db = Database::instance ();
00236   static LanguageVector& Languages = db.languages ();
00237 
00238   return (Languages);
00239 }

Language & Language::null  )  [static]
 

Definition at line 242 of file cmt_language.cxx.

Referenced by add(), LibraryGenerator::analyze_file(), find(), find_with_suffix(), LibraryGenerator::module_file_action(), and show().

00244 {
00245   static Language null_instance;
00246 
00247   return (null_instance);
00248 }

bool Language::operator!= const Language other  )  const
 

Definition at line 357 of file cmt_language.cxx.

00359 {
00360   if (this != &other) return (true);
00361   return (false);
00362 }

bool Language::operator== const Language other  )  const
 

Definition at line 349 of file cmt_language.cxx.

00351 {
00352   if (this == &other) return (true);
00353   return (false);
00354 }

bool Language::operator== const cmt_string name  )  const
 

Definition at line 341 of file cmt_language.cxx.

00343 {
00344   if (m_name == name) return (true);
00345   return (false);
00346 }

void Language::setup_all_fragments  )  [static]
 

Definition at line 65 of file cmt_language.cxx.

References languages(), LanguageVector, setup_fragments(), and cmt_vector< T >::size().

Referenced by CmtGenerator::reset().

00067 {
00068   static LanguageVector& Languages = languages ();
00069 
00070   int language_index;
00071 
00072   if (Languages.size () == 0) return;
00073 
00074   for (language_index = 0;
00075        language_index < Languages.size ();
00076        language_index++)
00077     {
00078       Language& language = Languages[language_index];
00079 
00080       language.setup_fragments ();
00081     }
00082 }

void Language::setup_fragments  ) 
 

Definition at line 328 of file cmt_language.cxx.

References application, fragment_name, library, and FragmentHandle::set().

Referenced by setup_all_fragments().

00330 {
00331   cmt_string n = fragment_name;
00332 
00333   application.set (n);
00334 
00335   n += "_library";
00336 
00337   library.set (n);
00338 }

void Language::show  ) 
 

Definition at line 278 of file cmt_language.cxx.

References extra_output_suffixes, fragment_name, linker, m_name, output_suffix, preprocessor_command, prototypes, cmt_vector< T >::size(), and suffixes.

Referenced by Cmt::do_show_language().

00280 {
00281   cout << "language " << m_name;
00282 
00283   int i;
00284 
00285   for (i = 0; i < (suffixes.size ()); i++)
00286     {
00287       cmt_string& suffix = suffixes[i];
00288       
00289       cout << " -suffix=" << suffix;
00290     }
00291 
00292   if (linker != "")
00293     {
00294       cout << " -linker=" << linker;
00295     }
00296 
00297   if (prototypes)
00298     {
00299       cout << " -prototypes";
00300     }
00301 
00302   if (preprocessor_command != "-I")
00303     {
00304       cout << " -preprocessor_command=" << preprocessor_command;
00305     }
00306 
00307   if (fragment_name != m_name)
00308     {
00309       cout << " -fragment=" << fragment_name;
00310     }
00311 
00312   if (output_suffix != "")
00313     {
00314       cout << " -output_suffix=" << output_suffix;
00315     }
00316 
00317   for (i = 0; i < extra_output_suffixes.size (); i++)
00318     {
00319       cmt_string& suffix = extra_output_suffixes[i];
00320       
00321       cout << " -extra_output_suffix=" << suffix;
00322     }
00323 
00324   cout << endl;
00325 }

void Language::show const cmt_string name  )  [static]
 

Definition at line 23 of file cmt_language.cxx.

References find(), and null().

Referenced by show_all().

00025 {
00026   Language& language = find (name);
00027 
00028   if (language == null ()) return;
00029 
00030   language.show ();
00031 }

void Language::show_all  )  [static]
 

Definition at line 34 of file cmt_language.cxx.

References languages(), LanguageVector, show(), and cmt_vector< T >::size().

Referenced by Cmt::do_show_languages().

00036 {
00037   static LanguageVector& Languages = languages ();
00038 
00039   int number;
00040 
00041   for (number = 0; number < Languages.size (); number++)
00042     {
00043       Language& language = Languages[number];
00044 
00045       language.show ();
00046     }
00047 }

void Language::show_names  )  [static]
 

Definition at line 50 of file cmt_language.cxx.

References languages(), LanguageVector, m_name, and cmt_vector< T >::size().

00052 {
00053   static LanguageVector& Languages = languages ();
00054 
00055   int number;
00056 
00057   for (number = 0; number < Languages.size (); number++)
00058     {
00059       Language& language = Languages[number];
00060       cout << language.m_name << endl;
00061     }
00062 }


Member Data Documentation

FragmentHandle Language::application
 

Definition at line 48 of file cmt_language.h.

Referenced by LibraryGenerator::module_file_action(), and setup_fragments().

CmtSystem::cmt_string_vector Language::extra_output_suffixes
 

Definition at line 46 of file cmt_language.h.

Referenced by action(), LibraryGenerator::analyze_file(), clear(), and show().

cmt_string Language::fragment_name
 

Definition at line 40 of file cmt_language.h.

Referenced by action(), add(), clear(), setup_fragments(), and show().

FragmentHandle Language::library
 

Definition at line 49 of file cmt_language.h.

Referenced by LibraryGenerator::module_file_action(), and setup_fragments().

cmt_string Language::linker
 

Definition at line 41 of file cmt_language.h.

Referenced by action(), LibraryGenerator::analyze_file(), clear(), and show().

cmt_string Language::m_name
 

Definition at line 39 of file cmt_language.h.

Referenced by add(), clear(), find(), show(), and show_names().

cmt_string Language::output_suffix
 

Definition at line 42 of file cmt_language.h.

Referenced by action(), LibraryGenerator::analyze_file(), clear(), and show().

cmt_string Language::preprocessor_command
 

Definition at line 44 of file cmt_language.h.

Referenced by action(), clear(), LibraryGenerator::module_file_action(), and show().

bool Language::prototypes
 

Definition at line 43 of file cmt_language.h.

Referenced by action(), LibraryGenerator::build(), clear(), and show().

CmtSystem::cmt_string_vector Language::suffixes
 

Definition at line 45 of file cmt_language.h.

Referenced by action(), clear(), find_with_suffix(), and show().


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