WvStreams
backslashex.cc
00001 #include "wvbackslash.h"
00002 #include "wvbufbase.h"
00003 
00004 int main()
00005 {
00006    WvBackslashEncoder *enc;
00007    enc = new WvBackslashEncoder("abcd");
00008    // enc contains the letters you want to escape (add a backslash to)
00009 
00010    // If you want a decoder, then enc has to be initialiazed like this:
00011    // enc = new WvBackslashDecoder();
00012 
00013    WvInPlaceBuf to_encode(20);
00014    WvInPlaceBuf out(40);
00015 
00016    to_encode.put("Test abcdefg",12);
00017    // to_encode contains the string to be encoded
00018    // (added a backslash at the correct spot)
00019 
00020    if (enc->encode(to_encode, out, true,true))
00021      printf ("This is the result: %s\n", (char *) out.get(1));
00022 
00023    // Displayed on screen:
00024    // This is the result: Test \a\b\c\defg
00025 
00026    return 0;
00027 }