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
11class WvLog;
12
20{
21public:
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
65protected:
66 WvLog *logp;
67
68public:
69 const char *wstype() const { return "WvProtoStream"; }
70};
71
72
73#endif // __WVPROTOSTREAM_H
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
Definition: wvlog.h:57
WvProtoStream is a framework that makes it easy to communicate using common command-response driven p...
Definition: wvprotostream.h:20
virtual void execute()
pass input through to the state machine, one line at a time
virtual size_t uwrite(const void *buffer, size_t size)
override uwrite() so we can log all output
int tokanal(const Token &t, const char **lookup, bool case_sensitive=false)
Convert token strings to enum values.
WvStreamClone simply forwards all requests to the "cloned" stream.
Definition: wvstreamclone.h:24
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition: wvstream.h:25
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:330
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