COIN-OR::LEMON - Graph Library

Changeset 2426:6e1027a05d73 in lemon-0.x for lemon


Ignore:
Timestamp:
04/19/07 17:14:34 (17 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3262
Message:

Allowing 'string' type quoting

Location:
lemon/bits
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/item_reader.h

    r2391 r2426  
    3131#include <list>
    3232#include <set>
     33#include <map>
     34
     35#include <lemon/error.h>
    3336
    3437namespace lemon {
     
    173176      value.clear();
    174177      is >> std::ws;
    175       if (!is.get(c) || c != '\"')
     178      if (!is.get(c) || (c != '\"' && c != '\''))
    176179        throw DataFormatError("Quoted format error");
    177       while (is.get(c) && c != '\"') {
     180      char quote = c;
     181      while (is.get(c) && c != quote) {
    178182        if (escaped && c == '\\') {
    179183          value += readEscape(is);
  • lemon/bits/item_writer.h

    r2391 r2426  
    3232#include <list>
    3333#include <set>
     34#include <map>
     35
     36#include <lemon/error.h>
    3437
    3538namespace lemon {
     
    147150    /// Constructor for the writer. If the given parameter is true
    148151    /// the writer creates escape sequences from special characters.
    149     QuotedStringWriter(bool _escaped = true) : escaped(_escaped) {}
     152    QuotedStringWriter(bool _escaped = true, char _quote = '\"')
     153      : escaped(_escaped), quote(_quote) {}
    150154
    151155    /// \brief Writes a quoted string to the given stream.
     
    153157    /// Writes a quoted string to the given stream.
    154158    void write(std::ostream& os, const std::string& value) const {
    155       os << "\"";
     159      os << quote;
    156160      if (escaped) {
    157161        std::ostringstream ls;
     
    163167        os << value;
    164168      }
    165       os << "\"";
     169      os << quote;
    166170    }
    167171
     
    214218  private:
    215219    bool escaped;
     220    char quote;
    216221  };
    217222
Note: See TracChangeset for help on using the changeset viewer.