WvStreams
wvprotostream.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  */
6 #ifndef __WVPROTOSTREAM_H
7 #define __WVPROTOSTREAM_H
8 
9 #include "wvstreamclone.h"
10 
11 class WvLog;
12 
20 {
21 public:
22  class Token
23  {
24  public:
25  WvString data;
26  size_t length;
27 
28  Token();
29  Token(const unsigned char *_data, size_t _length);
30  void fill(const unsigned char *_data, size_t _length);
31  ~Token();
32  };
33 
34  DeclareWvList(Token);
35 
36  WvDynBuf tokbuf;
37  bool log_enable;
38 
39  WvProtoStream(WvStream *_cloned, WvLog *_debuglog = NULL);
40  virtual ~WvProtoStream();
41 
43  virtual size_t uwrite(const void *buffer, size_t size);
44 
45  // Routines to convert an input line into a set of Tokens.
46  virtual Token *next_token();
47  WvString next_token_str();
48  WvString token_remaining();
49  virtual TokenList *tokenize();
50  size_t list_to_array(TokenList *tl, Token **array);
51  Token *tokline(const char *line);
52 
54  int tokanal(const Token &t, const char **lookup,
55  bool case_sensitive = false);
56 
57  // finite state machine
58  int state;
59  virtual void do_state(Token &t1);
60  virtual void switch_state(int newstate);
61 
63  virtual void execute();
64 
65 protected:
66  WvLog *logp;
67 
68 public:
69  const char *wstype() const { return "WvProtoStream"; }
70 };
71 
72 
73 #endif // __WVPROTOSTREAM_H
lookup
int lookup(const char *str, const char *const *table, bool case_sensitive=false)
Finds a string in an array and returns its index.
Definition: strutils.cc:850
WvProtoStream::execute
virtual void execute()
pass input through to the state machine, one line at a time
Definition: wvprotostream.cc:193
WvProtoStream::Token
Definition: wvprotostream.h:22
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
WvProtoStream
WvProtoStream is a framework that makes it easy to communicate using common command-response driven p...
Definition: wvprotostream.h:19
WvLog
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
Definition: wvlog.h:56
WvProtoStream::tokanal
int tokanal(const Token &t, const char **lookup, bool case_sensitive=false)
Convert token strings to enum values.
Definition: wvprotostream.cc:161
WvStreamClone
WvStreamClone simply forwards all requests to the "cloned" stream.
Definition: wvstreamclone.h:23
WvProtoStream::uwrite
virtual size_t uwrite(const void *buffer, size_t size)
override uwrite() so we can log all output
Definition: wvprotostream.cc:39
WvStream
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition: wvstream.h:24
WvDynBufBase< unsigned char >