WvStreams
backslashex.cc
1 #include "wvbackslash.h"
2 #include "wvbufbase.h"
3 
4 int main()
5 {
7  enc = new WvBackslashEncoder("abcd");
8  // enc contains the letters you want to escape (add a backslash to)
9 
10  // If you want a decoder, then enc has to be initialiazed like this:
11  // enc = new WvBackslashDecoder();
12 
13  WvInPlaceBuf to_encode(20);
14  WvInPlaceBuf out(40);
15 
16  to_encode.put("Test abcdefg",12);
17  // to_encode contains the string to be encoded
18  // (added a backslash at the correct spot)
19 
20  if (enc->encode(to_encode, out, true,true))
21  printf ("This is the result: %s\n", (char *) out.get(1));
22 
23  // Displayed on screen:
24  // This is the result: Test \a\b\c\defg
25 
26  return 0;
27 }
WvBackslashEncoder
An encoder that performs C-style backslash escaping of strings.
Definition: wvbackslash.h:22
WvEncoder::encode
bool encode(WvBuf &inbuf, WvBuf &outbuf, bool flush=false, bool finish=false)
Reads data from the input buffer, encodes it, and writes the result to the output buffer.
Definition: wvencoder.cc:36
WvInPlaceBuf
The in place raw memory buffer type.
Definition: wvbuf.h:164