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

PackageCollector Class Reference

This FileScanner actor collects all packages clients of the specified one. More...

Inheritance diagram for PackageCollector

Inheritance graph
[legend]
Collaboration diagram for PackageCollector:

Collaboration graph
[legend]
List of all members.

Public Methods

 PackageCollector (const cmt_string& package, const cmt_string& version)
void run (const cmt_string& package, const cmt_string& version, const cmt_string& path)
int count ()

Private Attributes

const cmt_stringm_package
const cmt_stringm_version
int m_count

Detailed Description

This FileScanner actor collects all packages clients of the specified one.

Definition at line 140 of file cmt_parser.cxx.


Constructor & Destructor Documentation

PackageCollector::PackageCollector ( const cmt_string & package,
const cmt_string & version )
 

Definition at line 408 of file cmt_parser.cxx.

00409                                                                :
00410   m_package (package), m_version (version), m_count (0)
00411 {
00412 }


Member Function Documentation

int PackageCollector::count ( )
 

Definition at line 514 of file cmt_parser.cxx.

Referenced by Cmt::do_show_clients().

00515 {
00516   return (m_count);
00517 }

void PackageCollector::run ( const cmt_string & package,
const cmt_string & version,
const cmt_string & path ) [virtual]
 

Reimplemented from FileScanner::actor.

Definition at line 415 of file cmt_parser.cxx.

00418 {
00419   cmt_string dir = path;
00420   dir += CmtSystem::file_separator ();
00421   dir += version;
00422   dir += CmtSystem::file_separator ();
00423 
00424   cmt_string req;
00425 
00426   req = dir;
00427   req += "cmt";
00428   req += CmtSystem::file_separator ();
00429   req += "requirements";
00430 
00431   cmt_string requirements;
00432   cmt_string line;
00433   CmtSystem::cmt_string_vector words;
00434 
00435   if (CmtSystem::test_file (req))
00436     {
00437       requirements.read (req);
00438     }
00439   else
00440     {
00441       req = dir;
00442       req += "mgr";
00443       req += CmtSystem::file_separator ();
00444       req += "requirements";
00445       if (CmtSystem::test_file (req))
00446         {
00447           requirements.read (req);
00448         }
00449     }
00450 
00451   if (requirements != "")
00452     {
00453       int pos = 0;
00454       int max_pos = requirements.size ();
00455 
00456       while (pos < max_pos)
00457         {
00458           int cr = requirements.find (pos, "\r\n");
00459           int nl = requirements.find (pos, '\n');
00460           int first = nl;
00461           int length = 1;
00462                 
00463           if (cr != cmt_string::npos)
00464             {
00465               if (nl == cmt_string::npos)
00466                 {
00467                   first = cr;
00468                   length = 2;
00469                 }
00470               else
00471                 {
00472                   first = (nl < cr) ? nl : cr;
00473                   length = (nl < cr) ? 1 : 2;
00474                 }
00475             }
00476                 
00477           if (first == cmt_string::npos)
00478             {
00479               requirements.substr (pos, line);
00480               pos = max_pos;
00481             }
00482           else if (first > pos)
00483             {
00484               requirements.substr (pos, first - pos, line);
00485               pos = first + length;
00486             }
00487           else
00488             {
00489               line.erase (0);
00490               pos += length;
00491             }
00492 
00493           CmtSystem::split (line, " \t", words);
00494 
00495           if ((words.size () > 2) && (words[0] == "use")) 
00496             {
00497               if ((words[1] == m_package) && 
00498                   ((words[2] == m_version) || (m_version == "")))
00499                 {
00500                   cout << "# " << package << " " << version << " " << path;
00501                   if (m_version == "")
00502                     {
00503                       cout << " (use version " << words[2] << ")";
00504                     }
00505                   cout << endl;
00506                   m_count++;
00507                 }
00508             }
00509         }
00510     }
00511 }


Member Data Documentation

int PackageCollector::m_count [private]
 

Definition at line 153 of file cmt_parser.cxx.

const cmt_string & PackageCollector::m_package [private]
 

Definition at line 151 of file cmt_parser.cxx.

const cmt_string & PackageCollector::m_version [private]
 

Definition at line 152 of file cmt_parser.cxx.


The documentation for this class was generated from the following file:
Generated at Thu May 16 16:27:54 2002 for CMT by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000