25 #ifndef UCOMMON_SYSRUNTIME
26 #ifndef _UCOMMON_STREAM_H_
27 #define _UCOMMON_STREAM_H_
29 #ifndef _UCOMMON_CONFIG_H
33 #ifndef _UCOMMON_PROTOCOLS_H_
37 #ifndef _UCOMMON_THREAD_H_
41 #ifndef _UCOMMON_SOCKET_H_
45 #ifndef _UCOMMON_FSYS_H_
49 #ifndef _UCOMMON_SHELL_H_
63 class __EXPORT
StreamBuffer :
protected std::streambuf,
public std::iostream
82 int uflow() __OVERRIDE;
86 void allocate(
size_t size);
95 inline bool is_open(
void)
const
98 inline operator bool()
const
101 inline bool operator!()
const
102 {
return bufsize == 0;}
116 __LOCAL
void allocate(
unsigned size);
117 __LOCAL
void reset(
void);
123 virtual ssize_t _read(
char *buffer,
size_t size);
125 virtual ssize_t _write(
const char *buffer,
size_t size);
127 virtual bool _wait(
void);
140 int underflow(
void) __OVERRIDE;
148 int overflow(
int ch) __OVERRIDE;
150 inline socket_t getsocket(
void)
const
173 tcpstream(
int family = PF_INET, timeout_t timeout = 0);
194 inline operator bool()
const
195 {
return so != INVALID_SOCKET && bufsize > 0;}
202 {
return so == INVALID_SOCKET || bufsize == 0;}
217 void open(
const char *host,
const char *service,
unsigned segment = 536);
244 __LOCAL
void allocate(
size_t size, access_t mode);
263 int underflow(
void) __OVERRIDE;
272 int overflow(
int ch) __OVERRIDE;
288 pipestream(
const char *command, access_t
access,
char **args,
char **env = NULL,
size_t size = 512);
299 inline operator bool()
const
300 {
return (bufsize > 0);}
307 {
return bufsize == 0;}
317 void open(
const char *path, access_t access,
char **args,
char **env = NULL,
size_t buffering = 512);
328 void terminate(
void);
330 inline void cancel(
void)
364 int underflow(
void) __OVERRIDE;
373 int overflow(
int ch) __OVERRIDE;
405 inline operator bool()
const
406 {
return (bufsize > 0);}
413 {
return bufsize == 0;}
418 void open(
const char *filename,
fsys::access_t access,
size_t buffering = 512);
423 void open(
const char *filename,
unsigned mode,
fsys::access_t access,
size_t buffering = 512);
439 inline int err(
void)
const
453 static std::ostream& print(std::ostream& out,
const PrintProtocol& format);
455 static std::istream& input(std::istream& inp,
InputProtocol& format);
457 static std::ostream& print(std::ostream& out,
const string_t& str);
459 static std::istream& input(std::istream& inp,
string_t& str);
461 static std::ostream& print(std::ostream& out,
const stringlist_t& list);
463 static std::istream& input(std::istream& in,
stringlist_t& list);
465 static std::string& append(std::string& target,
String& source);
468 inline std::ostream& operator<< (std::ostream& out,
const PrintProtocol& format)
469 {
return _stream_operators::print(out, format);}
471 inline std::istream& operator>> (std::istream& inp, InputProtocol& format)
472 {
return _stream_operators::input(inp, format);}
474 inline std::ostream& operator<< (std::ostream& out,
const string_t& str)
475 {
return _stream_operators::print(out, str);}
477 inline std::istream& operator>> (std::istream& inp,
string_t& str)
478 {
return _stream_operators::input(inp, str);}
480 inline std::ostream& operator<< (std::ostream& out,
const stringlist_t& list)
481 {
return _stream_operators::print(out, list);}
483 inline std::istream& operator>> (std::istream& in,
stringlist_t& list)
484 {
return _stream_operators::input(in, list);}
486 inline std::string& operator+(std::string& target, String& source)
487 {
return _stream_operators::append(target, source);}
489 inline std::string& operator+=(std::string& target, String& source)
490 {
return _stream_operators::append(target, source);}
492 inline std::ostream& operator<<(std::ostream& os, Socket::address&
addr) {
494 char buf[INET6_ADDRSTRLEN];
496 char buf[INET_ADDRSTRLEN];
498 addr.print(buf,
sizeof(buf),
false,
true);
void access(SharedAccess &object)
Convenience function to access (lock) shared object through it's protocol.
void release(SharedAccess &object)
Convenience function to unlock shared object through it's protocol.
StringPager stringlist_t
A convenience type for paged string lists.
Thread classes and sychronization objects.
Various miscellaneous platform specific headers and defines.
Common stream buffer for std C++ i/o classes.
Streamable tcp connection between client and server.
Thread-aware file system manipulation class.
int pid_t
Standard type of process id for shell class.
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.
A copy-on-write string class that operates by reference count.
A container for generic and o/s portable threadsafe file system functions.
access_t
Enumerated file access modes.
Used for forming stream output.
bool operator!() const
See if stream is disconnected.
struct sockaddr * addr(Socket::address &address)
A convenience function to convert a socket address list into a socket address.
long offset_t
File offset type.
Common socket class and address manipulation.
int err(void) const
Get error flag from last i/o operation.
bool operator!() const
See if stream is disconnected.
Streamable tcp connection between client and server.
Common namespace for all ucommon objects.
String pager for storing lists of NULL terminated strings.
Used for processing input.
bool operator!() const
See if stream is disconnected.
String string_t
A convenience type for string.
int err(void) const
Get last error.
Abstract interfaces and support.
Streamable tcp connection between client and server.
At least with gcc, linking of stream operators was broken.
A generic tcp server class.
Generic shell parsing and application services.
A generic socket address class.