JX Application Framework
|
#include "jStreamUtil.h"
#include "JString.h"
#include "JUtf8ByteBuffer.h"
#include "jFileUtil.h"
#include "jFStreamUtil.h"
#include "jErrno.h"
#include <poll.h>
#include <string.h>
#include <limits.h>
#include "jAssert.h"
Functions | |
void | JCopyBinaryData (std::istream &input, std::ostream &output, const JSize byteCount) |
JString | JRead (std::istream &input, const JSize count) |
void | JReadAll (std::istream &input, JString *str) |
JString | JReadLine (std::istream &input, bool *foundNewLine) |
JString | JReadUntil (std::istream &input, const JUtf8Byte delimiter, bool *foundDelimiter) |
bool | JReadUntil (std::istream &input, const JSize delimiterCount, const JUtf8Byte *delimiters, JString *str, JUtf8Byte *delimiter) |
JString | JReadUntilws (std::istream &input, bool *foundws) |
void | JIgnoreLine (std::istream &input, bool *foundNewLine) |
void | JIgnoreUntil (std::istream &input, const JUtf8Byte delimiter, bool *foundDelimiter) |
void | JIgnoreUntil (std::istream &input, const JUtf8Byte *delimiter, bool *foundDelimiter) |
bool | JIgnoreUntil (std::istream &input, const JSize delimiterCount, const JUtf8Byte *delimiters, JUtf8Byte *delimiter) |
void | JEncodeBase64 (std::istream &input, std::ostream &output) |
bool | JDecodeBase64 (std::istream &input, std::ostream &output) |
ssize_t | jRead (const int handle, void *buf, size_t len) |
ssize_t | jReadN (const int handle, void *buf, size_t len, size_t *bt) |
JString | JRead (const int input, const JSize count) |
bool | JReadAll (const int input, JString *str, const bool closeInput) |
JString | JReadUntil (const int input, const JUtf8Byte delimiter, bool *foundDelimiter) |
bool | JReadUntil (const int input, const JSize delimiterCount, const JUtf8Byte *delimiters, JString *str, JUtf8Byte *delimiter) |
void | JIgnoreUntil (const int input, const JUtf8Byte delimiter, bool *foundDelimiter) |
void | JIgnoreUntil (const int input, const JUtf8Byte *delimiter, bool *foundDelimiter) |
bool | JIgnoreUntil (const int input, const JSize delimiterCount, const JUtf8Byte *delimiters, JUtf8Byte *delimiter) |
bool | JWaitForInput (const int input, const time_t timeout) |
void JCopyBinaryData | ( | std::istream & | input, |
std::ostream & | output, | ||
const JSize | byteCount | ||
) |
Copies binary data from input to output. Caller must set initial read and write marks.
bool JDecodeBase64 | ( | std::istream & | input, |
std::ostream & | output | ||
) |
void JEncodeBase64 | ( | std::istream & | input, |
std::ostream & | output | ||
) |
void JIgnoreLine | ( | std::istream & | input, |
bool * | foundNewLine | ||
) |
Toss characters from the std::istream until newline ('
', '\r', '\r
') is reached. newline is read in and discarded.
If foundNewLine is not nullptr, it tells whether or not the end of a line was actually encountered.
bool JIgnoreUntil | ( | const int | input, |
const JSize | delimiterCount, | ||
const JUtf8Byte * | delimiters, | ||
JUtf8Byte * | delimiter | ||
) |
Toss characters from the std::istream until one of the delimiters is reached. delimiter is read in and discarded.
Returns true if a delimited is found. *delimiter is then set to the delimiter that was found.
Returns false if it encounters an error or end-of-stream instead of a delimiter. *delimiter is not changed.
delimiter can be nullptr.
This would be unnecessary if libstdc++ provided a stream wrapper for arbitrary file descriptors.
Discard characters from the std::istream until delimiter is reached. delimiter is read in and discarded.
If foundDelimiter is not nullptr, it tells whether or not the delimiter was actually found.
To keep the prototype as close to JReadUntil() as possible, foundDelimiter is not the return value.
This would be unnecessary if libstdc++ provided a stream wrapper for arbitrary file descriptors.
bool JIgnoreUntil | ( | std::istream & | input, |
const JSize | delimiterCount, | ||
const JUtf8Byte * | delimiters, | ||
JUtf8Byte * | delimiter | ||
) |
Toss characters from the std::istream until one of the delimiters is reached. delimiter is read in and discarded.
Returns true if a delimited is found. *delimiter is then set to the delimiter that was found.
Returns false if it encounters an error or end-of-stream instead of a delimiter. *delimiter is not changed.
delimiter can be nullptr.
Discard characters from the std::istream until delimiter is reached. delimiter is read in and discarded.
If foundDelimiter is not nullptr, it tells whether or not the delimiter was actually found.
To keep the prototype as close to JReadUntil() as possible, foundDelimiter is not the return value.
|
inline |
Stolen from ACE library because we don't want to use ACE_HANDLE. This is a HANDLE instead of an int on Windows.
Read the specified number of characters from the stream.
Read the specified number of characters from the stream.
Read characters until the end of the data stream is reached. This function takes a JString* because the contents of the stream could be very large, and returning a JString requires twice as much memory because of the copy constructor.
This would be unnecessary if libstdc++ provided a stream wrapper for arbitrary file descriptors.
void JReadAll | ( | std::istream & | input, |
JString * | str | ||
) |
Read characters from the std::istream until newline ('
', '\r', '\r
') is reached. newline is read in and discarded.
If foundNewLine is not nullptr, it tells whether or not the end of a line was actually encountered.
ssize_t jReadN | ( | const int | handle, |
void * | buf, | ||
size_t | len, | ||
size_t * | bt | ||
) |
bool JReadUntil | ( | const int | input, |
const JSize | delimiterCount, | ||
const JUtf8Byte * | delimiters, | ||
JString * | str, | ||
JUtf8Byte * | delimiter | ||
) |
Read characters from the std::istream until one of the delimiters is reached. delimiter is read in and discarded.
Returns true if a delimited is found. *delimiter is then set to the delimiter that was found.
Returns false if it encounters an error or end-of-stream instead of a delimiter. *delimiter is not changed.
delimiter can be nullptr.
This would be unnecessary if libstdc++ provided a stream wrapper for arbitrary file descriptors.
Read characters from the std::istream until delimiter is reached. delimiter is read in and discarded.
If foundDelimiter is not nullptr, it tells whether or not the delimiter was actually found.
bool JReadUntil | ( | std::istream & | input, |
const JSize | delimiterCount, | ||
const JUtf8Byte * | delimiters, | ||
JString * | str, | ||
JUtf8Byte * | delimiter | ||
) |
Read characters from the std::istream until one of the delimiters is reached. delimiter is read in and discarded.
Returns true if a delimited is found. *delimiter is then set to the delimiter that was found.
Returns false if it encounters an error or end-of-stream instead of a delimiter. *delimiter is not changed.
delimiter can be nullptr.
Read characters from the std::istream until delimiter is reached. delimiter is read in and discarded.
If foundDelimiter is not nullptr, it tells whether or not the delimiter was actually found.
Read characters from the std::istream until white-space is reached. white-space is read in and discarded.
If foundws is not nullptr, it tells whether or not whitespace was actually encountered.
bool JWaitForInput | ( | const int | input, |
const time_t | timeout | ||
) |
Wait until there is data available or until it times out. timeout is in seconds.