WvStreams
wvhex.h
Go to the documentation of this file.
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * Hex encoder and hex decoder.
6  */
7 #ifndef __WVHEX_H
8 #define __WVHEX_H
9 
10 #include "wvencoder.h"
11 
21 class WvHexEncoder : public WvEncoder
22 {
23  char alphabase;
24 
25 public:
33  WvHexEncoder(bool use_uppercase = false);
34  virtual ~WvHexEncoder() { }
35 
36 protected:
37  virtual bool _encode(WvBuf &in, WvBuf &out, bool flush);
38  virtual bool _reset(); // supported
39 };
40 
41 
53 class WvHexDecoder : public WvEncoder
54 {
55  bool issecond;
56  int first;
57 
58 public:
60  WvHexDecoder();
61  virtual ~WvHexDecoder() { }
62 
63 protected:
64  virtual bool _encode(WvBuf &in, WvBuf &out, bool flush);
65  virtual bool _reset(); // supported
66 };
67 
85 void hexify(char *obuf, const void *ibuf, size_t len);
86 
92 void unhexify(void *obuf, const char *ibuf);
93 
94 #endif // __WVHEX_H
WvEncoder
The base encoder class.
Definition: wvencoder.h:67
WvHexEncoder::WvHexEncoder
WvHexEncoder(bool use_uppercase=false)
Creates a hex encoder.
Definition: wvhex.cc:27
unhexify
void unhexify(void *obuf, const char *ibuf)
Reverse the operation performed by hexify().
Definition: wvhex.cc:104
WvHexDecoder::WvHexDecoder
WvHexDecoder()
Creates a hex decoder.
Definition: wvhex.cc:54
WvHexEncoder::_encode
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
Definition: wvhex.cc:40
WvHexDecoder::_encode
virtual bool _encode(WvBuf &in, WvBuf &out, bool flush)
Template method implementation of encode().
Definition: wvhex.cc:68
WvBufBase< unsigned char >
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers.
Definition: wvbuf.h:22
hexify
void hexify(char *obuf, const void *ibuf, size_t len)
Write the contents of the binary string of length 'len' pointed to by 'ibuf' into the output buffer '...
Definition: wvhex.cc:95
WvHexEncoder::_reset
virtual bool _reset()
Template method implementation of reset().
Definition: wvhex.cc:34
WvHexEncoder
A hex encoder.
Definition: wvhex.h:21
WvHexDecoder
A hex decoder.
Definition: wvhex.h:53
WvHexDecoder::_reset
virtual bool _reset()
Template method implementation of reset().
Definition: wvhex.cc:60
WvEncoder::flush
bool flush(WvBuf &inbuf, WvBuf &outbuf, bool finish=false)
Flushes the encoder and optionally finishes it.
Definition: wvencoder.h:163