Changeset 509


Ignore:
Timestamp:
Dec 8, 2007, 10:42:07 PM (14 years ago)
Author:
Peter Johansson
Message:

changed format of codons in config file. Also changed corresponding access function to return a pointer, allowing to return NULL when key is not found.

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Configuration.cc

    r508 r509  
    153153          }
    154154    }
    155     add_codon("*", "", "");
    156155  }
    157156
     
    171170
    172171
    173   const std::vector<std::pair<std::string, std::string> >&
     172  const std::vector<std::pair<std::string, std::string> >*
    174173  Configuration::parse_codon(std::string file_name) const
    175174  {
     
    178177      if (svndigest::equal(file_name.begin(), file_name.end(),
    179178                           i->first.begin(), i->first.end()) ) {
    180         return i->second;
     179        return &i->second;
    181180      }
    182181    }
    183     return string2codons_.back().second;
     182    return NULL;
    184183  }
    185184
     
    304303      os << "trac-root = " << conf.trac_root() << "\n";
    305304
    306     if (conf.string2codons_.size()>1) {
     305    if (!conf.string2codons_.empty()) {
    307306      os << "\n"
    308307         << "### Section for setting parsing modes\n"
     
    313312         << "### String \"<NEWLINE>\" can be used for codons containing newline"
    314313         << "\n### character: '\\n'\n"
    315          << "[parsing]\n";
    316       for (size_t i=0; i<conf.string2codons_.size()-1; ++i)
    317         for (size_t j=0; j<conf.string2codons_[i].second.size(); ++j)
    318           os << conf.string2codons_[i].first << " = "
    319              << trans_beg_code(conf.string2codons_[i].second[j].first)
     314         << "[parsing-codons]\n";
     315      for (size_t i=0; i<conf.string2codons_.size(); ++i) {
     316        os << conf.string2codons_[i].first << " = ";
     317        for (size_t j=0; j<conf.string2codons_[i].second.size(); ++j) {
     318          if (j)
     319            os << "  ;  ";
     320          os << trans_beg_code(conf.string2codons_[i].second[j].first)
    320321             << " : "
    321              << trans_end_code(conf.string2codons_[i].second[j].second)
    322              << "\n";
     322             << trans_end_code(conf.string2codons_[i].second[j].second);
     323        }
     324        os << "\n";
     325      }
    323326    }
    324 
    325327    return os;
    326328  }
  • trunk/lib/Configuration.h

    r508 r509  
    7070       \return vector of parse codons for the given \a file_name
    7171     */
    72     const std::vector<std::pair<std::string, std::string> >&
     72    const std::vector<std::pair<std::string, std::string> >*
    7373    parse_codon(std::string file_name) const;
    7474
Note: See TracChangeset for help on using the changeset viewer.