WvStreams
wvbackslash.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 2002 Net Integration Technologies, Inc.
4  *
5  * C-style backslash escaping and unescaping of strings.
6  */
7 #ifndef __WVBACKSLASH_H
8 #define __WVBACKSLASH_H
9 
10 #include "wvencoder.h"
11 
23 {
24  WvString nasties;
25 
26 public:
33  WvBackslashEncoder(WvStringParm _nasties = "\\\"");
34  virtual ~WvBackslashEncoder() { }
35 
36 protected:
37  virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush);
38  virtual bool _reset();
39 };
40 
41 
66 {
67  enum State
68  { Initial, Escape, Hex1, Hex2, Octal1, Octal2, Octal3 };
69  State state;
70  WvInPlaceBuf tmpbuf;
71  int value;
72 
73 public:
76  virtual ~WvBackslashDecoder() { }
77 
78 protected:
79  virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush);
80  virtual bool _reset();
81 
82 private:
83  bool flushtmpbuf(WvBuf &outbuf);
84 };
85 
86 #endif // __WVBACKSLASH_H
WvBackslashEncoder::_reset
virtual bool _reset()
Template method implementation of reset().
Definition: wvbackslash.cc:108
WvBackslashDecoder::WvBackslashDecoder
WvBackslashDecoder()
Creates a C-style backslash decoder.
Definition: wvbackslash.cc:116
WvEncoder
The base encoder class.
Definition: wvencoder.h:67
WvBackslashEncoder
An encoder that performs C-style backslash escaping of strings.
Definition: wvbackslash.h:22
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
WvInPlaceBuf
The in place raw memory buffer type.
Definition: wvbuf.h:164
WvBackslashDecoder::_encode
virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush)
Template method implementation of encode().
Definition: wvbackslash.cc:122
WvBufBase< unsigned char >
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers.
Definition: wvbuf.h:22
WvBackslashDecoder
An encoder that performs C-style backslash unescaping of strings.
Definition: wvbackslash.h:65
WvBackslashEncoder::_encode
virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush)
Template method implementation of encode().
Definition: wvbackslash.cc:45
WvEncoder::flush
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.
Definition: wvencoder.h:163
WvBackslashEncoder::WvBackslashEncoder
WvBackslashEncoder(WvStringParm _nasties="\\\"")
Creates a C-style backslash encoder.
Definition: wvbackslash.cc:39
WvBackslashDecoder::_reset
virtual bool _reset()
Template method implementation of reset().
Definition: wvbackslash.cc:243