Main Page Class Hierarchy Compound List File List Compound Members File Members

# Symbol Class Reference

`#include <cmt_symbol.h>`

Collaboration diagram for Symbol:

[legend]
List of all members.

## Public Types
typedef cmt_vector<Symbol> | SymbolVector
## Public Methods
| Symbol ()
| ~Symbol ()
bool | value_is_reflexive (const cmt_string& text) const
| Characterizes if a value is provided as the reference to itself. More...
void | add_value_to_list (CommandType command_type, Use* use, Tag* tag, const cmt_string& text)
int | valid (PrintMode mode)
int | print_clean (int tabs, PrintMode mode)
int | print (int tabs, PrintMode mode)
cmt_string | build_macro_value () const
cmt_string | clean_macro_value () const
cmt_string | resolve_macro_value (const cmt_string& tag_name = "")
void | show_macro (PrintMode mode)
## Public Attributes
ValueBuilder* | builder
cmt_string | name
ScopeType | scope
CommandType | command
SymbolValueList::SymbolValueListVector | value_lists
int | selected_value
## Static Public Methods
Symbol* | create (const cmt_string& name, CommandType command, ScopeType scope)
Symbol* | find (const cmt_string& name)
void | action (const CmtSystem::cmt_string_vector& words, CommandType command_type, Use* use)
int | is_selected (const cmt_string& name)
void | all_print (PrintMode mode)
void | all_print_clean (PrintMode mode)
int | symbol_number ()
SymbolVector& | symbols ()
Symbol& | symbol (int index)
void | clear_all ()
void | expand (cmt_string& text)

## Member Typedef Documentation

typedef cmt_vector<Symbol> Symbol::SymbolVector

| Definition at line 50 of file cmt_symbol.h.

## Constructor & Destructor Documentation

Symbol::Symbol ( | )

| Definition at line 745 of file cmt_symbol.cxx.
    00746 {
    00747   name = "";
    00748 }

Symbol::~Symbol ( | )

| Definition at line 751 of file cmt_symbol.cxx.
    00752 {
    00753 }

## Member Function Documentation

void Symbol::action ( | const CmtSystem::cmt_string_vector & words,
| CommandType command_type,
| Use * use )`[static]`

| Definition at line 570 of file cmt_symbol.cxx. Referenced by Cmt::select().
    00573 {
    00574   int number;
    00575   Symbol* symbol;
    00576   Tag* tag;
    00577
    00578   if (words.size () < 1) return;
    00579   cmt_string name = words[1];
    00580
    00581   if ((command_type == CommandSetupScript) ||
    00582       (command_type == CommandCleanupScript))
    00583     {
    00584       cmt_string full_name;
    00585
    00586       Symbol::expand (name);
    00587
    00588       if (name != "")
    00589         {
    00590           if (CmtSystem::absolute_path (name))
    00591             {
    00592               full_name = name;
    00593             }
    00594           else
    00595             {
    00596 #ifdef WIN32
    00597               full_name = "%";
    00598 #else
    00599               full_name = "${";
    00600 #endif
    00601               full_name += use->prefix;
    00602               full_name += "ROOT";
    00603 #ifdef WIN32
    00604               full_name += "%";
    00605 #else
    00606               full_name += "}";
    00607 #endif
    00608               full_name += CmtSystem::file_separator ();
    00609               if (use->style == cmt_style) full_name += "cmt";
    00610               else full_name += "mgr";
    00611               full_name += CmtSystem::file_separator ();
    00612               full_name += name;
    00613             }
    00614
    00615           symbol = create (full_name, command_type, Cmt::get_scope ());
    00616           symbol->add_value_to_list (command_type, use,
    00617                                      Tag::get_default (), full_name);
    00618         }
    00619     }
    00620   else
    00621     {
    00622       if (words.size () < 2) return;
    00623       const cmt_string& default_value = words[2];
    00624
    00625       if ((Cmt::get_current_access () == UserMode) &&
    00626           (Cmt::get_scope () == ScopePrivate)) return;
    00627
    00628       symbol = create (name, command_type, Cmt::get_scope ());
    00629
    00630       /*
    00631         Parse the default value.
    00632       */
    00633
    00634       symbol->add_value_to_list (command_type, use,
    00635                                  Tag::get_default (), default_value);
    00636
    00637       /*
    00638         Then parse all specific values
    00639
    00640         <tag> <value>
    00641         ...
    00642       */
    00643
    00644       number = 3;
    00645       while (number < (words.size () - 1))
    00646         {
    00647           const cmt_string& tag_name = words[number];
    00648           const cmt_string& value = words[number + 1];
    00649
    00650           tag = Tag::find (tag_name);
    00651           if (tag == 0)
    00652             {
    00653               tag = Tag::add (tag_name, PriorityUserTag, "use", use);
    00654             }
    00655
    00656           symbol->add_value_to_list (command_type, use, tag, value);
    00657
    00658           number += 2;
    00659         }
    00660
    00661       if (name == "CMTPATH")
    00662         {
    00663           Cmt::configure_cmt_path (use);
    00664         }
    00665       else if (name == "CMTSITE")
    00666         {
    00667           Cmt::configure_site_tag (use);
    00668         }
    00669       else if (name == "CMTCONFIG")
    00670         {
    00671             //cerr << "redefining CMTCONFIG" << endl;
    00672           Cmt::configure_tags (use);
    00673         }
    00674       else if (name == "CMTHOME")
    00675         {
    00676           Cmt::configure_home (use);
    00677         }
    00678       else if (name == "CMTUSERCONTEXT")
    00679         {
    00680           Cmt::configure_user_context (use);
    00681         }
    00682       else if (name.find ("_native_version") != cmt_string::npos)
    00683         {
    00684           cmt_string n = use->package;
    00685           n += "_native_version";
    00686
    00687           if (name == n)
    00688             {
    00689               use->set_native_version (true);
    00690             }
    00691         }
    00692     }
    00693 }

void Symbol::add_value_to_list ( | CommandType command_type,
| Use * use,
| Tag * tag,
| const cmt_string & text )

| Definition at line 811 of file cmt_symbol.cxx. Referenced by action().
    00815 {
    00816   SymbolValueList* value_list = 0;
    00817   bool is_reflexive = false;
    00818
    00819     //
    00820     // First pickup the most recent value_list
    00821     //
    00822   if (value_lists.size () > 0) value_list = &(value_lists.back ());
    00823
    00824     //
    00825     //  Create a new value list is we switch to another use or
    00826     //  if we switch to a new command_type (eg. switching from
    00827     //  macro to macro_append).
    00828     //
    00829   if ((value_list == 0) ||
    00830       (use != value_list->use) ||
    00831       (command_type != value_list->command_type) ||
    00832       (tag == Tag::get_default ()))
    00833     {
    00834       value_list = &(value_lists.add ());
    00835       value_list->use = use;
    00836       value_list->command_type = command_type;
    00837       value_list->values.clear ();
    00838       value_list->discarded = false;
    00839       value_list->is_reflexive = false;
    00840     }
    00841   else
    00842     {
    00843       value_list = &(value_lists[value_lists.size () - 1]);
    00844     }
    00845
    00846   is_reflexive = value_list->is_reflexive;
    00847
    00848     //
    00849     //  If the command_type is command_macro or command_set,
    00850     // this is considered as a full re-set of this symbol
    00851     //   In this case, we have to discard all previous values
    00852     //
    00853     //  However, we'd like to exclude from this logic the cases where
    00854     //  the value is **exactly*
    00855     //
    00856     //     $(<symbol>)
    00857     //     ${<symbol>}
    00858     //     %<symbol>%
    00859     //
    00860     //   which would then mean that we do not reset the value but rather
    00861     //  override it.
    00862     //
    00863
    00864     //
    00865     // Inside this value_list, we add this new tag-value pair.
    00866     //
    00867
    00868   if ((command_type == CommandMacro) ||
    00869       (command_type == CommandSet))
    00870     {
    00871         //
    00872         // Check whether we have to hide previous settings by this new definition
    00873         //  (of course this is only useful if there WERE previous settings)
    00874         //
    00875       if ((value_lists.size () >= 1) && (!is_reflexive))
    00876         {
    00877           if (value_is_reflexive (text))
    00878             {
    00879               value_list->is_reflexive = true;
    00880               is_reflexive = true;
    00881             }
    00882           else
    00883             {
    00884                 //cerr << "...discarding old values for symbol " << name << endl;
    00885
    00886               for (int i = 0; i < (value_lists.size () - 1); i++)
    00887                 {
    00888                   SymbolValueList& vl = value_lists[i];
    00889
    00890                   if ((vl.use != 0) &&
    00891                       (vl.use->discarded)) continue;
    00892
    00893                   vl.discarded = true;
    00894                 }
    00895             }
    00896         }
    00897     }
    00898
    00899   SymbolValue& value = value_list->values.add ();
    00900
    00901   value.tag = tag;
    00902   value.text = text;
    00903   value.selected = 0;
    00904 }

void Symbol::all_print ( | PrintMode mode )`[static]`

| Definition at line 925 of file cmt_symbol.cxx. Referenced by Cmt::print().
    00926 {
    00927   static SymbolVector& Symbols = symbols ();
    00928
    00929   int number;
    00930
    00931   if (Symbols.size () == 0) return;
    00932
    00933   for (number = 0; number < Symbol::symbol_number (); number++)
    00934     {
    00935       Symbol& symbol = Symbol::symbol (number);
    00936
    00937       if ((symbol.command == CommandSet) ||
    00938           (symbol.command == CommandAlias) ||
    00939           (symbol.command == CommandSetupScript))
    00940         {
    00941           if (symbol.print (1, mode))
    00942             {
    00943               if (mode == Bat)
    00944                 {
    00945                   cout << endl;
    00946                 }
    00947               else
    00948                 {
    00949                   //cout << "; ";
    00950                   cout << endl;
    00951                 }
    00952             }
    00953         }
    00954     }
    00955
    00956   for (number = 0; number < Symbol::symbol_number (); number++)
    00957     {
    00958       Symbol& symbol = Symbol::symbol (number);
    00959
    00960       if ((symbol.command != CommandPath) &&
    00961           (symbol.command != CommandPathAppend) &&
    00962           (symbol.command != CommandPathPrepend) &&
    00963           (symbol.command != CommandPathRemove)) continue;
    00964
    00965       if (symbol.print (1, mode))
    00966         {
    00967           if (mode == Bat)
    00968             {
    00969               cout << endl;
    00970             }
    00971           else
    00972             {
    00973               //cout << "; ";
    00974               cout << endl;
    00975             }
    00976         }
    00977     }
    00978 }

void Symbol::all_print_clean ( | PrintMode mode )`[static]`

| Definition at line 981 of file cmt_symbol.cxx. Referenced by Cmt::print_clean().
    00982 {
    00983   static SymbolVector& Symbols = symbols ();
    00984
    00985   int number;
    00986
    00987   if (Symbols.size () == 0) return;
    00988
    00989   for (number = Symbols.size () - 1; number >= 0; number--)
    00990     {
    00991       Symbol& symbol = Symbols[number];
    00992
    00993       if ((symbol.command == CommandSet) ||
    00994           (symbol.command == CommandAlias) ||
    00995           (symbol.command == CommandCleanupScript))
    00996         {
    00997           if (symbol.print_clean (0, mode))
    00998             {
    00999               cout << endl;
    01000             }
    01001         }
    01002     }
    01003
    01004   for (number = Symbols.size () - 1; number >= 0; number--)
    01005     {
    01006       Symbol& symbol = Symbols[number];
    01007
    01008       if ((symbol.command != CommandPath) &&
    01009           (symbol.command != CommandPathAppend) &&
    01010           (symbol.command != CommandPathPrepend) &&
    01011           (symbol.command != CommandPathRemove)) continue;
    01012
    01013       if (symbol.print_clean (0, mode))
    01014         {
    01015           cout << endl;
    01016         }
    01017     }
    01018 }

cmt_string Symbol::build_macro_value ( | ) const

| Definition at line 1209 of file cmt_symbol.cxx. Referenced by Cmt::configure_cmt_path(), Cmt::configure_home(), Cmt::configure_site_tag(), Cmt::configure_tags(), Cmt::configure_user_context(), Cmt::do_build_library_links(), Cmt::do_remove_library_links(), ApplicationAnalyzer::end(), LibraryAnalyzer::end(), CmtLock::lock(), print(), Cmt::set_standard_macros(), show_macro(), and CmtLock::unlock().
    01210 {
    01211   cmt_string temp;
    01212
    01213   temp = builder->build (*this);
    01214
    01215   return (temp);
    01216 }

cmt_string Symbol::clean_macro_value ( | ) const

| Definition at line 1219 of file cmt_symbol.cxx. Referenced by print_clean().
    01220 {
    01221   cmt_string temp;
    01222
    01223   temp = builder->clean (*this);
    01224
    01225   return (temp);
    01226 }

void Symbol::clear_all ( | )`[static]`

| Definition at line 1365 of file cmt_symbol.cxx. Referenced by Database::clear().
    01366 {
    01367   static SymbolVector& Symbols = symbols ();
    01368
    01369   Symbols.clear ();
    01370 }

Symbol * Symbol::create ( | const cmt_string & name,
| CommandType command,
| ScopeType scope )`[static]`

| Definition at line 465 of file cmt_symbol.cxx. Referenced by action().
    00468 {
    00469   static SymbolVector& Symbols = symbols ();
    00470
    00471   {
    00472     Symbol* symbol;
    00473
    00474     symbol = find (name);
    00475     if (symbol != 0) return (symbol);
    00476   }
    00477
    00478   Symbol& symbol = Symbols.add ();
    00479
    00480   symbol.name    = name;
    00481   symbol.scope   = scope;
    00482   symbol.command = command;
    00483
    00484   symbol.value_lists.clear ();
    00485
    00486   switch (command)
    00487     {
    00488     case CommandSet:
    00489     case CommandSetAppend:
    00490     case CommandSetPrepend:
    00491     case CommandSetRemove:
    00492       symbol.builder = &Set;
    00493       symbol.command = CommandSet;
    00494       break;
    00495     case CommandPath:
    00496     case CommandPathAppend:
    00497     case CommandPathPrepend:
    00498     case CommandPathRemove:
    00499       symbol.builder = &Path;
    00500       break;
    00501     case CommandAlias:
    00502       symbol.builder = &Set;
    00503       break;
    00504     case CommandMacro:
    00505     case CommandMacroAppend:
    00506     case CommandMacroPrepend:
    00507     case CommandMacroRemove:
    00508     case CommandMacroRemoveAll:
    00509       symbol.builder = &Macro;
    00510       symbol.command = CommandMacro;
    00511       break;
    00512     case CommandSetupScript:
    00513     case CommandCleanupScript:
    00514       symbol.builder = &Script;
    00515       break;
    00516     }
    00517
    00518   symbol.selected_value = -1;
    00519
    00520   return (&symbol);
    00521 }

void Symbol::expand ( | cmt_string & text )`[static]`

| Definition at line 1373 of file cmt_symbol.cxx. Referenced by Use::action(), action(), Generator::build_dependencies(), Generator::build_make_setup(), Cmt::configure_cmt_path(), CmtModel::display(), Cmt::do_build_library_links(), Cmt::do_filter(), Cmt::do_remove_library_links(), Constituent::parse(), MakefileGenerator::prepare_use_context(), Use::set(), MakefileGenerator::set_full_name(), and show_macro().
    01374 {
    01375   resolve_value (text);
    01376 }

Symbol * Symbol::find ( | const cmt_string & name )`[static]`

| Definition at line 524 of file cmt_symbol.cxx. Referenced by DepsBuilder::add_includes(), Cmt::configure_cmt_path(), Cmt::configure_home(), Cmt::configure_site_tag(), Cmt::configure_tags(), Cmt::configure_user_context(), create(), Cmt::do_build_library_links(), Cmt::do_remove_library_links(), Cmt::do_show_macro(), ApplicationAnalyzer::end(), LibraryAnalyzer::end(), is_selected(), CmtLock::lock(), resolve_macro_value(), resolve_value(), resolve_value_for_macros(), DepsBuilder::run(), Cmt::set_standard_macros(), Use::show_sub_uses(), CmtLock::unlock(), and Fragment::wincopy().
    00525 {
    00526   static SymbolVector& Symbols = symbols ();
    00527
    00528   int number;
    00529   Symbol* result = 0;
    00530
    00531   for (number = 0; number < Symbols.size (); number++)
    00532     {
    00533       Symbol& s = Symbols[number];
    00534
    00535       if (s.name == name)
    00536         {
    00537           result = &s;
    00538         }
    00539     }
    00540
    00541   return (result);
    00542 }

int Symbol::is_selected ( | const cmt_string & name )`[static]`

| Definition at line 696 of file cmt_symbol.cxx. Referenced by StandardMacroBuilder::fill_for_branches(), StandardMacroBuilder::fill_for_fincludes(), StandardMacroBuilder::fill_for_includes(), StandardMacroBuilder::fill_for_package(), StandardMacroBuilder::fill_for_package_tag(), StandardMacroBuilder::fill_for_tag(), StandardMacroBuilder::fill_for_use_ROOT(), StandardMacroBuilder::fill_for_use_cflags(), StandardMacroBuilder::fill_for_use_cppflags(), StandardMacroBuilder::fill_for_use_fflags(), StandardMacroBuilder::fill_for_use_fincludes(), StandardMacroBuilder::fill_for_use_includes(), StandardMacroBuilder::fill_for_use_libraries(), StandardMacroBuilder::fill_for_use_linkopts(), StandardMacroBuilder::fill_for_use_pp_cflags(), StandardMacroBuilder::fill_for_use_pp_cppflags(), StandardMacroBuilder::fill_for_use_pp_fflags(), StandardMacroBuilder::fill_for_use_requirements(), StandardMacroBuilder::fill_for_use_root(), StandardMacroBuilder::fill_for_use_stamps(), StandardMacroBuilder::fill_for_use_tag(), StandardMacroBuilder::fill_for_use_version(), and Cmt::set_standard_macros().
    00697 {
    00698   Symbol* symbol;
    00699   int number;
    00700   int value_number;
    00701
    00702   symbol = find (name);
    00703   if (symbol == 0) return (0);
    00704
    00705   if (symbol->value_lists.size () == 0) return (0);
    00706
    00707   for (number = 0;
    00708        number < symbol->value_lists.size ();
    00709        number++)
    00710     {
    00711       const SymbolValueList& value_list = symbol->value_lists[number];
    00712
    00713       if (value_list.discarded) continue;
    00714
    00715       if ((value_list.command_type == CommandMacro) ||
    00716           (value_list.command_type == CommandSet) ||
    00717           (value_list.command_type == CommandSetAppend) ||
    00718           (value_list.command_type == CommandSetPrepend) ||
    00719           (value_list.command_type == CommandSetRemove) ||
    00720           (value_list.command_type == CommandAlias))
    00721         {
    00722           for (value_number = 0;
    00723                value_number < value_list.values.size ();
    00724                value_number++)
    00725             {
    00726               Tag* tag;
    00727
    00728               SymbolValue& value = value_list.values[value_number];
    00729
    00730               tag = value.tag;
    00731               if ((tag == 0) ||
    00732                   (tag == Tag::get_default ()) ||
    00733                   (tag->selected != 0))
    00734                 {
    00735                   return (1);
    00736                 }
    00737             }
    00738         }
    00739     }
    00740
    00741   return (0);
    00742 }

int Symbol::print ( | int tabs,
| PrintMode mode )

| Definition at line 1115 of file cmt_symbol.cxx. Referenced by all_print().
    01116 {
    01117   int result = 0;
    01118   static cmt_string temp;
    01119
    01120   temp = build_macro_value ();
    01121
    01122   switch (command)
    01123     {
    01124       case CommandSet :
    01125       case CommandPath :
    01126       case CommandPathAppend :
    01127       case CommandPathPrepend :
    01128       case CommandPathRemove :
    01129         switch (mode)
    01130           {
    01131             case Csh :
    01132               cout << "setenv " << name <<
    01133                   " \"" << temp << "\"";
    01134               result = 1;
    01135               break;
    01136             case Sh :
    01137               cout << name <<
    01138                   "=\"" << temp <<
    01139                   "\"; export " << name;
    01140               result = 1;
    01141               break;
    01142             case Bat :
    01143               temp.replace_all ("/", "\\");
    01144               cout << "set " << name <<
    01145                   "=" << temp;
    01146               result = 1;
    01147               break;
    01148           }
    01149         break;
    01150       case CommandAlias :
    01151         switch (mode)
    01152           {
    01153             case Csh :
    01154               cout << "alias " << name <<
    01155                   " \"" << temp << "\"";
    01156               result = 1;
    01157               break;
    01158             case Sh :
    01159               cout << "alias " << name <<
    01160                   "=\"" << temp <<
    01161                   "\"; export " << name;
    01162               result = 1;
    01163               break;
    01164             case Bat :
    01165               cout << "set " << name <<
    01166                   "=" << temp;
    01167               result = 1;
    01168               break;
    01169           }
    01170         break;
    01171       default :
    01172         break;
    01173     }
    01174
    01175   if (temp != "")
    01176     {
    01177       switch (command)
    01178         {
    01179           case CommandSetupScript :
    01180             switch (mode)
    01181               {
    01182                 case Csh :
    01183                   cout << "if ( -f " << name << ".csh ) then" << endl;
    01184                   cout << "  source " << name << ".csh" << endl;
    01185                   cout << "endif" << endl;
    01186                   result = 1;
    01187                   break;
    01188                 case Sh :
    01189                   cout << "if test -f " << name << ".sh; then" << endl;
    01190                   cout << "  . " << name << ".sh" << endl;
    01191                   cout << "fi" << endl;
    01192                   result = 1;
    01193                   break;
    01194                 case Bat :
    01195                   cout << "call " << name;
    01196                   result = 1;
    01197                   break;
    01198               }
    01199             break;
    01200           default:
    01201             break;
    01202         }
    01203     }
    01204
    01205   return (result);
    01206 }

int Symbol::print_clean ( | int tabs,
| PrintMode mode )

| Definition at line 1021 of file cmt_symbol.cxx. Referenced by all_print_clean().
    01022 {
    01023   int result = 0;
    01024   static cmt_string temp;
    01025
    01026   if (name == "CMTCONFIG") return (0);
    01027
    01028   switch (command)
    01029     {
    01030     case CommandSet :
    01031       switch (mode)
    01032         {
    01033         case Csh :
    01034           cout << "unsetenv " << name;
    01035           result = 1;
    01036           break;
    01037         case Sh :
    01038           cout << "unset " << name;
    01039           result = 1;
    01040           break;
    01041         case Bat :
    01042           cout << "set " << name << "=";
    01043           result = 1;
    01044           break;
    01045         }
    01046       break;
    01047     case CommandAlias :
    01048       switch (mode)
    01049         {
    01050           case Csh :
    01051             cout << "unalias " << name;
    01052             result = 1;
    01053             break;
    01054           case Sh :
    01055             cout << "unset " << name;
    01056             result = 1;
    01057             break;
    01058         }
    01059       break;
    01060     case CommandPath :
    01061     case CommandPathAppend :
    01062     case CommandPathPrepend :
    01063     case CommandPathRemove :
    01064       temp = clean_macro_value ();
    01065       switch (mode)
    01066         {
    01067         case Csh :
    01068           if (temp == "")
    01069             {
    01070               cout << "unsetenv " << name;
    01071             }
    01072           else
    01073             {
    01074               cout << "setenv " << name << " " << temp;
    01075             }
    01076           result = 1;
    01077           break;
    01078         case Sh :
    01079           cout << name << "=" << temp << "; export " << name;
    01080           result = 1;
    01081           break;
    01082         case Bat :
    01083           cout << "set " << name << "=" << temp;
    01084           result = 1;
    01085           break;
    01086         }
    01087       break;
    01088     case CommandCleanupScript :
    01089       switch (mode)
    01090         {
    01091         case Csh :
    01092           cout << "if ( -f " << name << ".csh ) then" << endl;
    01093           cout << "  source " << name << ".csh" << endl;
    01094           cout << "endif" << endl;
    01095           result = 1;
    01096           break;
    01097         case Sh :
    01098           cout << "if test -f " << name << ".sh; then" << endl;
    01099           cout << "  . " << name << ".sh" << endl;
    01100           cout << "fi" << endl;
    01101           result = 1;
    01102           break;
    01103         case Bat :
    01104           cout << "call " << name;
    01105           result = 1;
    01106           break;
    01107         }
    01108       break;
    01109     }
    01110
    01111   return (result);
    01112 }

cmt_string Symbol::resolve_macro_value ( | const cmt_string & tag_name = "" )

| Definition at line 1229 of file cmt_symbol.cxx. Referenced by DepsBuilder::add_includes(), DepsBuilder::run(), Use::show_sub_uses(), and Fragment::wincopy().
    01230 {
    01231   cmt_string temp = builder->build (*this, tag_name);
    01232   cmt_string pattern;
    01233   cmt_string macro_name;
    01234   char end_pattern;
    01235
    01236   int start = 0;
    01237
    01238   for (;;)
    01239     {
    01240       int begin;
    01241       int end;
    01242
    01243       symbol_marker markers[3];
    01244
    01245       markers[0].set (temp.find (start, "$("), ')', 2);
    01246       markers[1].set (temp.find (start, "${"), '}', 2);
    01247       markers[2].set (temp.find (start, "%"), '%', 1);
    01248
    01249       // Find the first of three patterns
    01250
    01251       symbol_marker& marker = symbol_marker::get_lowest (markers, 2);
    01252
    01253       begin = marker.ptr;
    01254
    01255       if (begin == cmt_string::npos) break;
    01256
    01257       end_pattern = marker.pattern;
    01258       start = begin + marker.intro;
    01259
    01260       end = temp.find (start, end_pattern);
    01261       if (end == cmt_string::npos)
    01262         {
    01263           // The pattern is a fake one (no ending!)
    01264           start++;
    01265           continue;
    01266         }
    01267
    01268       if (end < begin) break;
    01269
    01270       temp.substr (begin, end - begin + 1, pattern);
    01271       temp.substr (begin + marker.intro, end - begin - marker.intro, macro_name);
    01272       Symbol* macro = find (macro_name);
    01273       if (macro != 0)
    01274         {
    01275           // Macro found
    01276           cmt_string value = macro->resolve_macro_value (tag_name);
    01277           temp.replace_all (pattern, value);
    01278           start = begin;
    01279         }
    01280       else
    01281         {
    01282           // Macro not found. Look for env. variable
    01283           cmt_string value = CmtSystem::getenv (macro_name);
    01284           temp.replace_all (pattern, value);
    01285           start = begin;
    01286         }
    01287     }
    01288
    01289   return (temp);
    01290 }

void Symbol::show_macro ( | PrintMode mode )

| Definition at line 1293 of file cmt_symbol.cxx. Referenced by Cmt::do_show_macro(), and Cmt::print_macros().
    01294 {
    01295   ActionType action = Cmt::get_action ();
    01296
    01297   cmt_string value = build_macro_value ();
    01298
    01299   if ((!Cmt::get_quiet ()) &&
    01300       (action != action_build_tag_makefile) &&
    01301       (action != action_show_macros) &&
    01302       (action != action_show_sets))
    01303     {
    01304       cout << "#" << endl;
    01305       cout << "# Selection : " << endl;
    01306     }
    01307
    01308   if (value.size () > 0)
    01309     {
    01310       if ((action == action_show_macro) ||
    01311           (action == action_show_macros) ||
    01312           (action == action_show_sets) ||
    01313           (action == action_show_set) ||
    01314           (action == action_build_tag_makefile) ||
    01315           (action == action_load) ||
    01316           (!Cmt::get_quiet ()))
    01317         {
    01318           if (mode == Make)
    01319             {
    01320               cout << name << "=";
    01321             }
    01322           else
    01323             {
    01324               cout << name << "='";
    01325             }
    01326         }
    01327
    01328       if ((action == action_show_macro_value) ||
    01329           (action == action_show_set_value))
    01330         {
    01331           expand (value);
    01332         }
    01333       else if (action == action_build_tag_makefile)
    01334         {
    01335           suppress_OS_delimiters (value);
    01336         }
    01337
    01338       cout << value;
    01339
    01340       if ((action == action_show_macro) ||
    01341           (action == action_show_macros) ||
    01342           (action == action_show_sets) ||
    01343           (action == action_show_set) ||
    01344           (action == action_build_tag_makefile) ||
    01345           (action == action_load) ||
    01346           (!Cmt::get_quiet ()))
    01347         {
    01348           if (mode != Make)
    01349             {
    01350               cout << "'";
    01351             }
    01352 #ifdef WIN32
    01353           else
    01354             {
    01355               cout << " ";
    01356             }
    01357 #endif
    01358         }
    01359
    01360       cout << endl;
    01361     }
    01362 }

Symbol & Symbol::symbol ( | int index )`[static]`

| Definition at line 562 of file cmt_symbol.cxx. Referenced by all_print(), Cmt::print_macros(), and Cmt::print_symbol_names().
    00563 {
    00564   static SymbolVector& Symbols = symbols ();
    00565
    00566   return (Symbols[index]);
    00567 }

int Symbol::symbol_number ( | )`[static]`

| Definition at line 545 of file cmt_symbol.cxx. Referenced by all_print(), Cmt::print_macros(), and Cmt::print_symbol_names().
    00546 {
    00547   static SymbolVector& Symbols = symbols ();
    00548
    00549   return (Symbols.size ());
    00550 }

Symbol::SymbolVector & Symbol::symbols ( | )`[static]`

| Definition at line 553 of file cmt_symbol.cxx. Referenced by all_print(), all_print_clean(), clear_all(), create(), find(), symbol(), and symbol_number().
    00554 {
    00555   static Database& db = Database::instance ();
    00556   static SymbolVector& Symbols = db.symbols ();
    00557
    00558   return (Symbols);
    00559 }

int Symbol::valid ( | PrintMode mode )

| Definition at line 910 of file cmt_symbol.cxx.
    00911 {
    00912   int result = 0;
    00913
    00914   if (command == CommandMacro) return (0);
    00915   if (command == CommandMacroPrepend) return (0);
    00916   if (command == CommandMacroAppend) return (0);
    00917   if (command == CommandMacroRemove) return (0);
    00918   if (command == CommandMacroRemoveAll) return (0);
    00919   if (scope != Cmt::get_scope ()) return (0);
    00920
    00921   return (1);
    00922 }

bool Symbol::value_is_reflexive ( | const cmt_string & text ) const

| Characterizes if a value is provided as the reference to itself. Definition at line 758 of file cmt_symbol.cxx. Referenced by add_value_to_list(), MacroBuilder::build(), PathBuilder::build(), and SetBuilder::build().
    00759 {
    00760   bool result = false;
    00761   int text_length = text.size ();
    00762
    00763   if (text_length == (name.size () + 3))
    00764     {
    00765       static cmt_string temp;
    00766
    00767       if (text[0] == '$')
    00768         {
    00769           if (text[1] == '(')
    00770             {
    00771               temp = "$(";
    00772               temp += name;
    00773               temp += ")";
    00774
    00775               if (text == temp)
    00776                 {
    00777                   result = true;
    00778                 }
    00779             }
    00780           else if (text[1] == '{')
    00781             {
    00782               temp = "${";
    00783               temp += name;
    00784               temp += "}";
    00785
    00786               if (text == temp)
    00787                 {
    00788                   result = true;
    00789                 }
    00790             }
    00791         }
    00792     }
    00793   else if (text_length == (name.size () + 2))
    00794     {
    00795       static cmt_string temp;
    00796
    00797       temp = "%";
    00798       temp += name;
    00799       temp += "%";
    00800
    00801       if (text == temp)
    00802         {
    00803           result = true;
    00804         }
    00805     }
    00806
    00807   return (result);
    00808 }

## Member Data Documentation

ValueBuilder * Symbol::builder

| Definition at line 85 of file cmt_symbol.h.

CommandType Symbol::command

| Definition at line 89 of file cmt_symbol.h.

cmt_string Symbol::name

| Definition at line 87 of file cmt_symbol.h.

ScopeType Symbol::scope

| Definition at line 88 of file cmt_symbol.h.

int Symbol::selected_value

| Definition at line 93 of file cmt_symbol.h.

SymbolValueList::SymbolValueListVector Symbol::value_lists

| Definition at line 91 of file cmt_symbol.h.

The documentation for this class was generated from the following files:

- cmt_symbol.h
- cmt_symbol.cxx