I recently ran into a problem caused by using fstream::eof(). I read the following line from here:
The function eof() returns true if the end of the associated input file has been reached, false otherwise.
and (mistakenly) assumed this meant that if I used fstream::read() and read past the end of the file, the function eof() would...
Greetings. I'm just getting started with the boost::asio library and have run into some early difficulty related to boost::asio::ip::tcp::iostream.
My question has two parts:
1.) How does one connect an iostream using simply host and port number?
I can make the client and server [boost.org] examples work fine as coded. The server sp...
While, compiling a package, written in C++ on RHEL 5.0. I am getting the following error.
> error: nocreate is not a member of std::ios
The source-code corresponds to:
ifstream tempStr(argv[4],ios::in|ios::nocreate);
I have tried
#g++ -O -Wno-deprecated <file.cpp> -o <file>
as well as:
#g++ -O -o <file>
Please sugg...
I want to output my own object to a STL stream but with customized formatting. I came up with something like this but since I never used locale and imbue before I have no idea if this makes sense and how to implement MyFacet and operator<<.
So my questions are: does this make sense and how to implement MyFacet and operator<< ?
The foll...
I have a RichTextBox and I want to save the text to a file. Each line of the RichTextBox are ended with CR+LF ("\n\r") but when i save it to a file, the lines only contains the LF char at the end.
If I copy the content to the clipboard instead of a file all goes right (The content of the clipboar has CR+LF at the end of each line, I ca...
I'm a C++ developer who has primarily programmed on Solaris and Linux until recently, when I was forced to create an application targeted to Windows.
I've been using a communication design based on C++ I/O stream backed by TCP socket. The design is based on a single thread reading continuously from the stream (most of the time blocked i...
I've been writing a binary version of iostreams. It essentially allows you to write binary files, but gives you much control over the format of the file. Example usage:
my_file << binary::u32le << my_int << binary::u16le << my_string;
Would write my_int as a unsigned 32-bit integer, and my_string as a length-prefixed string (where the...
Is it possible to make a custom stream work like the stanadrd ones in regard for errors? That is by default use the good/fail/bad/eof bits rather than exceptions?
The boost docs only mention throwing an std::failure for stream errors and letting other error propagate (eg a badalloc from trying to allocate a buffer), however the boost co...
How would one go about doing this? Also, is there an easy way to do it? Using a lib like Boost or something?
...
I hardly find a good resource about the subject. Almost all books and websites I know give a simple introduction about streams in C++ and that's it!
Would you recommend a good book or tutorial to learn more about standard streams in C++ ?
...
I am attempting to read from a url into a System.IO.Stream object. I tried to use
Dim stream as Stream = New FileStream(msgURL, FileMode.Open)
but I get an error that URI formats are not supported with FileStream objects. Is there some method I can use that inherits from System.IO.Stream that is able to read from a URL?
...
I need to bridge two libraries over a stream.
QDataStream which is a stream from Qt
and some function from another libraries that looks like this
void read_something(istream& i);
I have no control over how the QDataStream is created and I'm not allowed to change the interface of read_somthing function.
The first thing I can think ...
Given two stream-oriented I/O objects in Asio, what is the simplest way to forward data from one device to the other in both directions? Could this be done with boost::iostreams::combination or boost::iostreams:copy perhaps? Or is a manual approach better--waiting for data on each end and then writing it out to the other stream? In other...
I am working on some legacy code which opens a file and adds binary data to the file:
std::ifstream mInFile;
#ifdef WINDOWS
miWindowsFileHandle = _sopen(filename.c_str(), O_RDONLY , SH_DENYWR, S_IREAD);
#endif
mInFile.open(filename.c_str(), std::ios_base::binary);
For some reason the code opens the file twice...
I'd like to scope-limit the effect of I/O stream formatting in C++, so that I can do something like this:
std::cout << std::hex << ...
if (some_condition) {
scoped_iofmt localized(std::cout);
std::cout << std::oct << ...
}
// outside the block, we're now back to hex
so that base, precision, fill, etc. are restored to their previo...
I am currently writing an app on the Blackberry to do a simple send and receive of some raw data to another TCP based device on my network. I am having the same problem in the Blackberry simulator w/ an MDS simulator running and using a physical phone talking to my company's MDS server. Note this problem does not happen when using wifi d...
i need to read in data files which look like this:
* SZA: 10.00
2.648 2.648 2.648 2.648 2.648 2.648 2.648 2.649 2.650 2.650
2.652 2.653 2.652 2.653 2.654 2.654 2.654 2.654 2.654 2.654
2.654 2.654 2.654 2.655 2.656 2.656 2.657 2.657 2.657 2.656
2.656 2.655 2.655 2.653 2.653 2.653 2.654 2.658 2.66...
I have a fileupload control that allows users to upload images but before they can upload images I want to resize thomse images to mas 640x480 size the problem is I can't figure out what to do next. This is what I have;
// CALL THE FUNCTION THAT WILL RESIZE THE IMAGE
protected void btnUploadFile_Click(object sender, EventArgs e)
{
S...
In this answer I talk about using a std::ifstream object's conversion to bool to test whether the stream is still in a good state. I looked in the Josuttis book for more information (p. 600 if you're interested), and it turns out that the iostream objects actually overload operator void*. It returns a null pointer when the stream is ba...
I have a data structure defined as
struct myDataStruct
{
int32_t header;
int16_t data[8];
}
and I want to take a character stream and turn it into a myData stream. What stream class should I extend? I would like to create a custom stream class so that I can do things like
myDataStruct myData;
myDataStruct myDataArray[10];
my...