24 #if defined(OLD_STDCPP) || defined(NEW_STDCPP)
25 #ifndef _UCOMMON_STREAM_H_
26 #define _UCOMMON_STREAM_H_
28 #ifndef _UCOMMON_CONFIG_H
32 #ifndef _UCOMMON_PROTOCOLS_H_
36 #ifndef _UCOMMON_THREAD_H_
40 #ifndef _UCOMMON_SOCKET_H_
44 #ifndef _UCOMMON_FSYS_H_
48 #ifndef _UCOMMON_SHELL_H_
62 class __EXPORT
StreamBuffer :
protected std::streambuf,
public std::iostream
82 void allocate(
size_t size);
91 inline bool is_open(
void)
const
94 inline operator bool()
const
97 inline bool operator!()
const
98 {
return bufsize == 0;}
112 __LOCAL
void allocate(
unsigned size);
113 __LOCAL
void reset(
void);
119 virtual ssize_t _read(
char *buffer,
size_t size);
121 virtual ssize_t _write(
const char *buffer,
size_t size);
123 virtual bool _wait(
void);
144 int overflow(
int ch);
146 inline socket_t getsocket(
void)
const
190 inline operator bool()
const
191 {
return so != INVALID_SOCKET && bufsize > 0;}
198 {
return so == INVALID_SOCKET || bufsize == 0;}
213 void open(
const char *host,
const char *service,
unsigned segment = 536);
240 __LOCAL
void allocate(
size_t size, access_t mode);
266 int overflow(
int ch);
282 pipestream(
const char *command, access_t
access,
char **args,
char **env = NULL,
size_t size = 512);
293 inline operator bool()
const
294 {
return (bufsize > 0);}
301 {
return bufsize == 0;}
311 void open(
const char *path, access_t access,
char **args,
char **env = NULL,
size_t buffering = 512);
322 void terminate(
void);
324 inline void cancel(
void)
367 int overflow(
int ch);
399 inline operator bool()
const
400 {
return (bufsize > 0);}
407 {
return bufsize == 0;}
412 void open(
const char *filename,
fsys::access_t access,
size_t buffering = 512);
417 void open(
const char *filename,
unsigned mode,
fsys::access_t access,
size_t buffering = 512);
433 inline int err(
void)
const
447 static std::ostream& print(std::ostream& out,
const PrintProtocol& format);
449 static std::istream& input(std::istream& inp,
InputProtocol& format);
451 static std::ostream& print(std::ostream& out,
const string_t& str);
453 static std::istream& input(std::istream& inp,
string_t& str);
455 static std::ostream& print(std::ostream& out,
const stringlist_t& list);
457 static std::istream& input(std::istream& in,
stringlist_t& list);
459 static std::string& append(std::string& target,
String& source);
462 inline std::ostream& operator<< (std::ostream& out,
const PrintProtocol& format)
463 {
return _stream_operators::print(out, format);}
465 inline std::istream& operator>> (std::istream& inp, InputProtocol& format)
466 {
return _stream_operators::input(inp, format);}
468 inline std::ostream& operator<< (std::ostream& out,
const string_t& str)
469 {
return _stream_operators::print(out, str);}
471 inline std::istream& operator>> (std::istream& inp,
string_t& str)
472 {
return _stream_operators::input(inp, str);}
474 inline std::ostream& operator<< (std::ostream& out,
const stringlist_t& list)
475 {
return _stream_operators::print(out, list);}
477 inline std::istream& operator>> (std::istream& in,
stringlist_t& list)
478 {
return _stream_operators::input(in, list);}
480 inline std::string& operator+(std::string& target, String& source)
481 {
return _stream_operators::append(target, source);}
483 inline std::string& operator+=(std::string& target, String& source)
484 {
return _stream_operators::append(target, source);}
486 inline std::ostream& operator<<(std::ostream& os, Socket::address&
addr) {
488 char buf[INET6_ADDRSTRLEN];
490 char buf[INET_ADDRSTRLEN];
492 addr.print(buf,
sizeof(buf),
false,
true);
Abstract interfaces and support.
String string_t
A convenience type for string.
void access(SharedAccess &object)
Convenience function to access (lock) shared object through it's protocol.
unsigned long timeout_t
Typedef for millisecond timer values.
A copy-on-write string class that operates by reference count.
A generic tcp server class.
Common namespace for all ucommon objects.
A container for generic and o/s portable threadsafe file system functions.
bool operator!() const
See if stream is disconnected.
access_t
Enumerated file access modes.
void release(SharedAccess &object)
Convenience function to unlock shared object through it's protocol.
Various miscellaneous platform specific headers and defines.
At least with gcc, linking of stream operators was broken.
String pager for storing lists of NULL terminated strings.
int err(void) const
Get last error.
Generic shell parsing and application services.
Thread-aware file system manipulation class.
Common stream buffer for std C++ i/o classes.
bool operator!() const
See if stream is disconnected.
Streamable tcp connection between client and server.
Thread classes and sychronization objects.
Streamable tcp connection between client and server.
A generic socket address class.
Common socket class and address manipulation.
int err(void) const
Get error flag from last i/o operation.
Used for processing input.
struct sockaddr * addr(Socket::address &address)
A convenience function to convert a socket address list into a socket address.
Used for forming stream output.
long offset_t
File offset type.
Streamable tcp connection between client and server.
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.
bool operator!() const
See if stream is disconnected.
StringPager stringlist_t
A convenience type for paged string lists.