COIN-OR::LEMON - Graph Library

Changeset 1533:43c7b3085212 in lemon-0.x


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

Specialization for string literals.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/item_writer.h

    r1435 r1533  
    5757      os << "\"";
    5858      if (escaped) {
    59         std::ostringstream ls;
     59        std::ostringstream ls(value);
    6060        for (int i = 0; i < (int)value.size(); ++i) {
    6161          writeEscape(ls, value[i]);
     
    117117    bool escaped;
    118118  };
     119
     120  /// \ingroup item_io
     121  /// \brief Writer class for quoted char array.
     122  ///
     123  /// Writer class for quoted char array. It can process the escape
     124  /// sequences in the char array.
     125  /// \author Balazs Dezso
     126  class QuotedCharArrayWriter {
     127  public:
     128    typedef const char* Value;
     129
     130    /// \brief Constructor for the writer.
     131    ///
     132    /// Constructor for the writer. If the given parameter is true
     133    /// the writer creates escape sequences from special characters.
     134    QuotedCharArrayWriter(bool _escaped = true) : escaped(_escaped) {}
     135
     136    /// \brief Writes a quoted char array to the given stream.
     137    ///
     138    /// Writes a quoted char array to the given stream.
     139    void write(std::ostream& os, const char* value) {
     140      QuotedStringWriter(escaped).write(os, std::string(value));
     141    }
     142
     143  private:   
     144    bool escaped;
     145  };
     146
    119147
    120148  /// \ingroup item_io
     
    182210    : public QuotedStringWriter {};
    183211
     212  template <int length>
     213  class DefaultWriter<char[length]>
     214    : public QuotedCharArrayWriter {};
     215
     216  template <int length>
     217  class DefaultWriter<const char[length]>
     218    : public QuotedCharArrayWriter {};
     219
    184220  template <typename Item>
    185221  class DefaultWriter<std::vector<Item> >
     
    211247
    212248    template <typename _Value>
    213     struct Writer : DefaultWriter<_Value> {};
     249    struct Writer : DefaultWriter<_Value> {
     250      typedef DefaultWriter<_Value> Parent;
     251    };
    214252
    215253  };
Note: See TracChangeset for help on using the changeset viewer.