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