JX Application Framework
Loading...
Searching...
No Matches
Functions
jStreamUtil.cpp File Reference
#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"
Include dependency graph for jStreamUtil.cpp:

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)
 

Function Documentation

◆ JCopyBinaryData()

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.

◆ JDecodeBase64()

bool JDecodeBase64 ( std::istream &  input,
std::ostream &  output 
)

◆ JEncodeBase64()

void JEncodeBase64 ( std::istream &  input,
std::ostream &  output 
)

◆ JIgnoreLine()

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.

◆ JIgnoreUntil() [1/6]

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.

◆ JIgnoreUntil() [2/6]

void JIgnoreUntil ( const int  input,
const JUtf8Byte delimiter,
bool foundDelimiter 
)

◆ JIgnoreUntil() [3/6]

void JIgnoreUntil ( const int  input,
const JUtf8Byte  delimiter,
bool foundDelimiter 
)

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.

◆ JIgnoreUntil() [4/6]

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.

◆ JIgnoreUntil() [5/6]

void JIgnoreUntil ( std::istream &  input,
const JUtf8Byte delimiter,
bool foundDelimiter 
)

◆ JIgnoreUntil() [6/6]

void JIgnoreUntil ( std::istream &  input,
const JUtf8Byte  delimiter,
bool foundDelimiter 
)

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.

◆ jRead()

ssize_t jRead ( const int  handle,
void *  buf,
size_t  len 
)
inline

Stolen from ACE library because we don't want to use ACE_HANDLE. This is a HANDLE instead of an int on Windows.

◆ JRead() [1/2]

JString JRead ( const int  input,
const JSize  count 
)

Read the specified number of characters from the stream.

◆ JRead() [2/2]

JString JRead ( std::istream &  input,
const JSize  count 
)

Read the specified number of characters from the stream.

◆ JReadAll() [1/2]

bool JReadAll ( const int  input,
JString str,
const bool  closeInput 
)

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.

◆ JReadAll() [2/2]

void JReadAll ( std::istream &  input,
JString str 
)

Read characters until the end of the std::istream 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.

Not inline to avoid including JString.h in header file.

◆ JReadLine()

JString JReadLine ( std::istream &  input,
bool foundNewLine 
)

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.

◆ jReadN()

ssize_t jReadN ( const int  handle,
void *  buf,
size_t  len,
size_t *  bt 
)

◆ JReadUntil() [1/4]

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.

◆ JReadUntil() [2/4]

JString JReadUntil ( const int  input,
const JUtf8Byte  delimiter,
bool foundDelimiter 
)

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.

◆ JReadUntil() [3/4]

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.

◆ JReadUntil() [4/4]

JString JReadUntil ( std::istream &  input,
const JUtf8Byte  delimiter,
bool foundDelimiter 
)

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.

◆ JReadUntilws()

JString JReadUntilws ( std::istream &  input,
bool foundws 
)

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.

◆ JWaitForInput()

bool JWaitForInput ( const int  input,
const time_t  timeout 
)

Wait until there is data available or until it times out. timeout is in seconds.