libassa 3.5.1
Loading...
Searching...
No Matches
xdrIOBuffer.h
Go to the documentation of this file.
1// -*- c++ -*-
2//------------------------------------------------------------------------------
3// xdrIOBuffer.h
4//------------------------------------------------------------------------------
5// Copyright (c) 2000,2005 by Vladislav Grinchenko
6//
7// This library is free software; you can redistribute it and/or
8// modify it under the terms of the GNU Library General Public
9// License as published by the Free Software Foundation; either
10// version 2 of the License, or (at your option) any later version.
11//------------------------------------------------------------------------------
12// Created: 04/03/2000
13//------------------------------------------------------------------------------
14
15#ifndef XDR_IO_BUFFER_H
16#define XDR_IO_BUFFER_H
17
18#include "assa/Assure.h"
19#include "assa/Socket.h"
20#include "assa/IPv4Socket.h"
21
22#include <string>
23
24namespace ASSA {
25
56{
57public:
66
70
73 ~xdrIOBuffer ();
74
78
82
87
90 xdrIOBuffer& operator>>(std::string&);
91
95
98 xdrIOBuffer& operator>>(float&);
99
102 operator void*() const;
103
106 string get_state () const;
107
112 int size () const;
113
116 int buffer_size () const;
117
120 const char* str () const;
121
125 void reset ();
126
129 void dump () const;
130
131protected:
133 void copy (const xdrIOBuffer&);
134
135private:
137 char* m_buf;
138
140 int m_sz;
141
143 char* m_ptr;
144
147};
148
149inline
152{
153 trace_with_mask("xdrIOBuffer::xdrIOBuffer(xdrIOBuffer&)", XDRBUFTRACE);
154
155 copy (rhs_);
156}
157
158inline
159xdrIOBuffer::
160operator void*() const
161{
162 trace_with_mask("xdrIOBuffer::opt void*()", XDRBUFTRACE);
163
164 return (m_state == waiting || m_state == parsed)
165 ? (void *)0 // bad state
166 : (void *)(-1); // good state
167}
168
169inline int
171size () const
172{
173 return (m_ptr - m_buf);
174}
175
176inline int
178buffer_size () const
179{
180 return (m_sz);
181}
182
183inline const char*
185str () const
186{
187 return ((const char*) m_buf);
188}
189
190} // end namespace ASSA
191
192#endif /* XDR_IO_BUFFER_H */
A collection of assert function wrappers.
Class IPv4Socket covers domain types AF_INET and AF_UNIX.
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition Logger.h:437
Abstraction of socket data type.
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
void copy(const xdrIOBuffer &)
Copy object from argument.
xdrIOBuffer(u_int len_)
Constructor.
void reset()
Clear up the internal buffer and reset state to waiting.
int m_sz
Buffer size and maximum expected size.
char * m_ptr
Pointer for next I/O operation into the buffer
int size() const
Return number of bytes in xdrIOBuffer.
~xdrIOBuffer()
Destructor.
state_t m_state
Object state.
const char * str() const
Return pointer to the first byte of xdrIOBuffer.
friend Socket & operator>>(Socket &src_, xdrIOBuffer &dest_)
Read raw data from Socket nonblocking and store into internal buffer.
char * m_buf
Buffer.
string get_state() const
Give verbal interpretation of object's state.
xdrIOBuffer & operator=(const xdrIOBuffer &rhs_)
Assign operator.
void dump() const
Dump object's internal state to the log file.
int buffer_size() const
Return buffer (maximum expected/allowable) size.
@ XDRBUFTRACE
Extended xdrIOBuffer messages
Definition LogMask.h:44