COIN-OR::LEMON - Graph Library

Changeset 1133:9fd485470fee in lemon-0.x for src/work/deba/graph_reader.h


Ignore:
Timestamp:
02/07/05 11:48:14 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1532
Message:

Documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/deba/graph_reader.h

    r1115 r1133  
    7474
    7575
    76   // Readers and ReaderTraits
    7776  /// \brief Standard ReaderTraits for the GraphReader class.
    7877  ///
    79   ///
    80  
     78  /// Standard ReaderTraits for the GraphReader class.
     79  /// It defines standard reading method for all type of value.
    8180  struct DefaultReaderTraits {
    8281
     82    /// \brief Template class for reading an value.
     83    ///
     84    /// Template class for reading an value.
    8385    template <typename _Value>
    8486    struct Reader {
     87      /// The value type.
    8588      typedef _Value Value;
     89      /// \brief Reads a value from the given stream.
     90      ///
     91      /// Reads a value from the given stream.
    8692      void read(std::istream& is, Value& value) {
    8793        if (!(is >> value))
     
    9096    };
    9197
     98    /// The reader class for the not needed maps.
    9299    typedef Reader<std::string> DefaultReader;
    93100
    94101  };
    95102
     103  /// \brief Reader class for quoted strings.
     104  ///
     105  /// Reader class for quoted strings. It can process the escape
     106  /// sequences in the string.
    96107  class QuotedStringReader {
    97108  public:
    98109    typedef std::string Value;
    99 
     110   
     111    /// \brief Constructor for the reader.
     112    ///
     113    /// Constructor for the reader. If the given parameter is true
     114    /// the reader processes the escape sequences.
    100115    QuotedStringReader(bool _escaped = true) : escaped(_escaped) {}
    101 
     116   
     117    /// \brief Reads a quoted string from the given stream.
     118    ///
     119    /// Reads a quoted string from the given stream.
    102120    void read(std::istream& is, std::string& value) {
    103121      char c;
     
    146164        {
    147165          int code;
    148           if (!is.get(c) || !isHex(c)) throw DataFormatException("Escape format exception");
     166          if (!is.get(c) || !isHex(c))
     167            throw DataFormatException("Escape format exception");
    149168          else if (code = valueHex(c), !is.get(c) || !isHex(c)) is.putback(c);
    150169          else code = code * 16 + valueHex(c);
     
    154173        {
    155174          int code;
    156           if (!isOct(c)) throw DataFormatException("Escape format exception");
    157           else if (code = valueOct(c), !is.get(c) || !isOct(c)) is.putback(c);
    158           else if (code = code * 8 + valueOct(c), !is.get(c) || !isOct(c)) is.putback(c);
     175          if (!isOct(c))
     176            throw DataFormatException("Escape format exception");
     177          else if (code = valueOct(c), !is.get(c) || !isOct(c))
     178            is.putback(c);
     179          else if (code = code * 8 + valueOct(c), !is.get(c) || !isOct(c))
     180            is.putback(c);
    159181          else code = code * 8 + valueOct(c);
    160182          return code;
     
    172194
    173195   static bool isHex(char c) {
    174       return ('0' <= c && c <= '9') || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
     196      return ('0' <= c && c <= '9') ||
     197        ('a' <= c && c <= 'z') ||
     198        ('A' <= c && c <= 'Z');
    175199    }
    176200   
     
    184208  };
    185209
    186 
    187 
    188 
    189 
    190   // Graph reader
    191  
     210  /// \brief The graph reader class.
     211  ///
     212  /// The reader class for the graph input.
     213  /// \see graph-io-page
    192214  template <typename _Graph, typename _ReaderTraits = DefaultReaderTraits>
    193215  class GraphReader {
     
    201223    typedef typename ReaderTraits::DefaultReader DefaultReader;
    202224
     225    /// \brief Construct a new GraphReader.
     226    ///
     227    /// Construct a new GraphReader. It reads from the given map,
     228    /// it constructs the given map and it use the given reader as the
     229    /// default skipper.
    203230    GraphReader(std::istream& _is, Graph& _graph,
    204231                const DefaultReader& _reader = DefaultReader())
    205232      : is(_is), graph(_graph), nodeSkipper(_reader), edgeSkipper(_reader) {}
    206233
    207 
     234    /// \brief Destruct the graph reader.
     235    ///
     236    /// Destruct the graph reader.
    208237    ~GraphReader() {
    209238
     
    220249    }
    221250
    222     // Node map rules
    223 
     251    /// \brief Add a new node map reader command for the reader.
     252    ///
     253    /// Add a new node map reader command for the reader.
    224254    template <typename Map>
    225255    GraphReader& addNodeMap(std::string name, Map& map) {
     
    228258    }
    229259
     260    /// \brief Add a new node map reader command for the reader.
     261    ///
     262    /// Add a new node map reader command for the reader.
    230263    template <typename Reader, typename Map>
    231264    GraphReader& addNodeMap(std::string name, Map& map,
     
    239272    }
    240273
     274    /// \brief Add a new node map skipper command for the reader.
     275    ///
     276    /// Add a new node map skipper command for the reader.
    241277    template <typename Reader>
    242278    GraphReader& skipNodeMap(std::string name,
     
    250286    }
    251287
    252     // Edge map rules
    253 
     288    /// \brief Add a new edge map reader command for the reader.
     289    ///
     290    /// Add a new edge map reader command for the reader.
    254291    template <typename Map>
    255292    GraphReader& addEdgeMap(std::string name, Map& map) {
     
    259296
    260297
     298    /// \brief Add a new edge map reader command for the reader.
     299    ///
     300    /// Add a new edge map reader command for the reader.
    261301    template <typename Reader, typename Map>
    262302    GraphReader& addEdgeMap(std::string name, Map& map,
     
    270310    }
    271311
     312    /// \brief Add a new edge map skipper command for the reader.
     313    ///
     314    /// Add a new edge map skipper command for the reader.
    272315    template <typename Reader>
    273316    GraphReader& skipEdgeMap(std::string name,
     
    281324    }
    282325
    283     // Node rules
     326    /// \brief Add a new labeled node reader for the reader.
     327    ///
     328    /// Add a new labeled node reader for the reader.
    284329    GraphReader& addNode(std::string name, Node& node) {
    285330      if (node_readers.find(name) != node_readers.end()) {
     
    290335    }
    291336
    292     // Edge rules
    293 
     337    /// \brief Add a new labeled edge reader for the reader.
     338    ///
     339    /// Add a new labeled edge reader for the reader.
    294340    GraphReader& addEdge(std::string name, Edge& edge) {
    295341      if (edge_readers.find(name) != edge_readers.end()) {
     
    300346    }
    301347
    302     void read() {
     348    /// \brief Executes the reader commands.
     349    ///
     350    /// Executes the reader commands.
     351    void run() {
    303352      int line_num = 0;
    304353      std::auto_ptr<InverterBase<Node> > nodeInverter;
Note: See TracChangeset for help on using the changeset viewer.