Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync 1128 #214

Merged
merged 9 commits into from
Nov 28, 2017
7 changes: 0 additions & 7 deletions externals/coda-oss/modules/c++/dbi/tests/SQLTest2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ int main(int argc, char* argv[])

resultSet = myConn->query("CREATE TABLE MyTable (id INT NOT NULL PRIMARY KEY, name VARCHAR(25) NOT NULL, description TEXT NOT NULL)");

char document[5];
document[0] = 'J';
document[1] = 'E';
document[2] = '\0';
document[3] = 'F';
document[4] = 'F';

resultSet = myConn->query("SELECT TMODEL_KEY, NAME, OVERVIEW_URL FROM TMODEL");

myRow = resultSet->fetchRow();
Expand Down
25 changes: 13 additions & 12 deletions externals/coda-oss/modules/c++/io/include/io/ByteStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,11 @@ class ByteStream : public SeekableInputStream, public SeekableOutputStream

/*!
* Writes the bytes in data to the stream.
* \param b the data to write to the stream
* \param buffer the data to write to the stream
* \param size the number of bytes to write to the stream
*/
virtual
void write(const sys::byte *b, sys::Size_T size);

/*!
* Read up to len bytes of data from this buffer into an array
* update the mark
* \param b Buffer to read into
* \param len The length to read
* \throw IoException
* \return The number of bytes read
*/
virtual sys::SSize_T read(sys::byte *b, sys::Size_T len);
void write(const void* buffer, size_t size);

void reset()
{
Expand Down Expand Up @@ -137,6 +127,17 @@ class ByteStream : public SeekableInputStream, public SeekableOutputStream
return mData.size();
}

protected:
/*!
* Read up to len bytes of data from this buffer into an array
* update the mark
* \param buffer Buffer to read into
* \param len The length to read
* \throw IoException
* \return The number of bytes read
*/
virtual sys::SSize_T readImpl(void* buffer, size_t len);

private:
std::vector<sys::ubyte> mData;
sys::Off_T mPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ class CountingOutputStream: public ProxyOutputStream

using ProxyOutputStream::write;

virtual void write(const sys::byte* b, sys::Size_T len)
/*!
* \param buffer The byte array to write to the stream
* \param len The length of the byte array to write to the stream
*/
virtual void write(const void* buffer, size_t len)
{
ProxyOutputStream::write(b, len);
ProxyOutputStream::write(buffer, len);
mByteCount += len;
}

Expand Down
23 changes: 12 additions & 11 deletions externals/coda-oss/modules/c++/io/include/io/DataStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,12 @@ class DataStream: public io::Serializable
return mStringStream.available();
}

/*!
* Read bytes from our byte stream into the buffer
* \param data The data buffer to read to
* \param size The size of the data buffer to read
*/
virtual sys::SSize_T read(sys::byte* data, sys::Size_T size)
{
return mStringStream.read(data, size);
}

/*!
* Write bytes from into our byte stream from the buffer
* \param data The data buffer to read from
* \param size The size of the data buffer.
*/
virtual void write(const sys::byte* data, sys::Size_T size)
virtual void write(const void* data, sys::Size_T size)
{
mStringStream.write(data, size);
}
Expand Down Expand Up @@ -108,7 +98,18 @@ class DataStream: public io::Serializable
{
return mStringStream;
}

protected:
/*!
* Read bytes from our byte stream into the buffer
* \param data The data buffer to read to
* \param size The size of the data buffer to read
*/
virtual sys::SSize_T readImpl(void* data, sys::Size_T size)
{
return mStringStream.read(data, size);
}

io::StringStream mStringStream;
};
}
Expand Down
6 changes: 3 additions & 3 deletions externals/coda-oss/modules/c++/io/include/io/DbgStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ class DbgStream : public OutputStream
/*!
* This method uses the bound OutputStream to print,
* if the switch is on.
* \param b The byte array to write to the stream
* \param buffer The byte array to write to the stream
* \param len The length
* \throw IOException
*/
virtual void write(const sys::byte* b, sys::Size_T len)
virtual void write(const void* buffer, sys::Size_T len)
{
if (mOn)
{
mStream->write(b, len);
mStream->write(buffer, len);
}
}

Expand Down
24 changes: 13 additions & 11 deletions externals/coda-oss/modules/c++/io/include/io/FileInputStreamIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,6 @@ class FileInputStreamIOS : public SeekableInputStream

//! Close the file
void close();
//using InputStream::read;
/*!
* Read up to len bytes of data from input stream into an array
*
* \param b Buffer to read into
* \param len The length to read
* \throw except::IOException
* \return The number of bytes read
*
*/
virtual sys::SSize_T read(sys::byte* b, sys::Size_T len);

/*!
* Access the stream directly
Expand All @@ -141,7 +130,20 @@ class FileInputStreamIOS : public SeekableInputStream
{
return mFStream;
}

protected:
/*!
* Read up to len bytes of data from input stream into an array
*
* \param buffer Buffer to read into
* \param len The length to read
* \throw except::IOException
* \return The number of bytes read
*
*/
virtual sys::SSize_T readImpl(void* buffer, size_t len);


std::ifstream mFStream;
};

Expand Down
10 changes: 4 additions & 6 deletions externals/coda-oss/modules/c++/io/include/io/FileInputStreamOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,19 @@ class FileInputStreamOS : public SeekableInputStream
mFile.close();
}

protected:
/*!
* Read up to len bytes of data from input stream into an array
*
* \param b Buffer to read into
* \param buffer Buffer to read into
* \param len The length to read
* \throw except::IOException
* \return The number of bytes read
*
*/
virtual sys::SSize_T read(sys::byte* b, sys::Size_T len);

virtual sys::SSize_T readImpl(void* buffer, size_t len);
};



}

#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ class FileOutputStreamIOS : public OutputStream
* This method defines a given OutputStream. By defining,
* this method, you can define the unique attributes of an OutputStream
* inheriting class.
* \param b The byte array to write to the stream
* \param buffer The byte array to write to the stream
* \param len the length of bytes to write
* \throw IoException
*/
virtual void write(const sys::byte* b, sys::Size_T len);
virtual void write(const void* buffer, size_t len);
/*!
* Access the stream directly
* \return The stream in native C++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,11 @@ class FileOutputStreamOS : public SeekableOutputStream
* This method defines a given OutputStream. By defining,
* this method, you can define the unique attributes of an OutputStream
* inheriting class.
* \param b The byte array to write to the stream
* \param buffer The byte array to write to the stream
* \param len the length of bytes to write
* \throw IoException
*/
virtual void write(const sys::byte* b, sys::Size_T len);



virtual void write(const void* buffer, size_t len);
};
}

Expand Down
20 changes: 17 additions & 3 deletions externals/coda-oss/modules/c++/io/include/io/InputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ class InputStream

/*!
* Read up to len bytes of data from input stream into an array
* \param b Buffer to read into
* \param buffer Buffer to read into
* \param len The length to read
* \param verifyFullRead If set to true, checks to see if 'len' bytes
* were read and, if not, throws. Defaults to false.
* \throw IOException
* \return The number of bytes read, or -1 if EOF
* \return The number of bytes read, or -1 if EOF. If 'verifyFullRead'
* is true, this will always return 'len' bytes if it didn't throw.
*/
virtual sys::SSize_T read(sys::byte* b, sys::Size_T len) = 0;
sys::SSize_T read(void* buffer,
size_t len,
bool verifyFullRead = false);

/*!
* Read either a buffer of len size, or up until a newline,
Expand All @@ -112,6 +117,15 @@ class InputStream
virtual sys::SSize_T streamTo(OutputStream& soi,
sys::SSize_T numBytes = IS_END);

protected:
/*!
* Read up to len bytes of data from input stream into an array
* \param buffer Buffer to read into
* \param len The length to read
* \throw IOException
* \return The number of bytes read, or -1 if EOF
*/
virtual sys::SSize_T readImpl(void* buffer, size_t len) = 0;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,9 @@ class MMapInputStream : public SeekableInputStream
return mMark;
}

virtual ssize_t read(sys::byte* b, size_t len);




protected:
virtual sys::SSize_T readImpl(void* buffer, size_t len);

virtual void _map();
virtual void _unmap();
sys::OS mOs;
Expand Down
36 changes: 17 additions & 19 deletions externals/coda-oss/modules/c++/io/include/io/NullStreams.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ class NullInputStream : public InputStream
return mAvailable;
}

virtual sys::SSize_T read(sys::byte* b, sys::Size_T len)
{
sys::Size_T numToRead =
(mAvailable >= (sys::SSize_T) len ? len : (sys::Size_T) mAvailable);

mAvailable -= (sys::SSize_T) numToRead;

if (numToRead == 0)
throw except::IOException(Ctxt("EOF - no more data to read"));

processBytes(b, numToRead);
return numToRead;
}

virtual sys::SSize_T readln(sys::byte *cStr,
const sys::Size_T strLenPlusNullByte)
{
Expand All @@ -85,10 +71,24 @@ class NullInputStream : public InputStream
{
return (sys::byte) 0;
}
virtual void processBytes(sys::byte* b, sys::Size_T len) const
virtual void processBytes(void* buffer, sys::Size_T len) const
{
//override for different behavior
memset(b, 0, len);
memset(buffer, 0, len);
}

virtual sys::SSize_T readImpl(void* buffer, size_t len)
{
size_t numToRead =
(mAvailable >= (sys::SSize_T) len ? len : (size_t) mAvailable);

mAvailable -= (sys::SSize_T) numToRead;

if (numToRead == 0)
throw except::IOException(Ctxt("EOF - no more data to read"));

processBytes(buffer, numToRead);
return numToRead;
}
};

Expand All @@ -114,16 +114,14 @@ class NullOutputStream : public OutputStream
{
}

virtual void write(const sys::byte* , sys::Size_T )
virtual void write(const void* , size_t )
{
}

virtual void flush()
{
}

};

}

#endif
5 changes: 2 additions & 3 deletions externals/coda-oss/modules/c++/io/include/io/OutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ class OutputStream
* This method defines a given OutputStream. By defining,
* this method, you can define the unique attributes of an OutputStream
* inheriting class.
* \param b The byte array to write to the stream
* \param buffer The byte array to write to the stream
* \param len The length of the byte array to write to the stream
* \throw IOException
*/
virtual void write(const sys::byte* b, sys::Size_T len) = 0;
virtual void write(const void* buffer, size_t len) = 0;

/*!
* Flush the stream if needed
Expand All @@ -107,7 +107,6 @@ class OutputStream
virtual void close()
{
}

};
}

Expand Down
12 changes: 5 additions & 7 deletions externals/coda-oss/modules/c++/io/include/io/PipeStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ class PipeStream : InputStream
return mExecPipe.closePipe();
}

/*!
* \func read
* \brief returns the requested size in bytes from the stream
*/
virtual sys::SSize_T read(sys::byte* b, sys::Size_T len);

/*!
* \func readln
* \brief returns one line ending in a newline or the requested size --
Expand All @@ -101,8 +95,12 @@ class PipeStream : InputStream
virtual sys::SSize_T streamTo(OutputStream& soi,
sys::SSize_T numBytes = IS_END);


protected:
/*!
* \brief returns the requested size in bytes from the stream
*/
virtual sys::SSize_T readImpl(void* buffer, size_t len);


sys::ExecPipe mExecPipe;
mem::ScopedArray<char> mCharString;
Expand Down
Loading