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

[legend]
Collaboration diagram for PackageCollector:

[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_string& | m_package
const cmt_string& | m_version
int | m_count

## Detailed Description

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

Definition at line 141 of file cmt_parser.cxx.

## Constructor & Destructor Documentation

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

| Definition at line 409 of file cmt_parser.cxx.
    00410                                                                :
    00411   m_package (package), m_version (version), m_count (0)
    00412 {
    00413 }

## Member Function Documentation

int PackageCollector::count ( | )

| Definition at line 515 of file cmt_parser.cxx. Referenced by Cmt::do_show_clients().
    00516 {
    00517   return (m_count);
    00518 }

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

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

## Member Data Documentation

int PackageCollector::m_count`[private]`

| Definition at line 154 of file cmt_parser.cxx.

const cmt_string & PackageCollector::m_package`[private]`

| Definition at line 152 of file cmt_parser.cxx.

const cmt_string & PackageCollector::m_version`[private]`

| Definition at line 153 of file cmt_parser.cxx.

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

- cmt_parser.cxx