Best way to copy between two Stream instances - C#
What is the best way to copy the contents of one stream to another? Is there a standard utility method for this? ...
What is the best way to copy the contents of one stream to another? Is there a standard utility method for this? ...
$fp_src=fopen('file','r'); $filter = stream_filter_prepend($fp_src, 'convert.iconv.ISO-8859-1/UTF-8'); while(fread($fp_src,4096)){ ++$count; if($count%1000==0) print ftell($fp_src)."\n"; } When I run this the script ends up consuming ~ 200 MB of RAM after going through just 35MB of the file. Running it without the stream_f...
GNU gcc 4.3 partially supports the upcoming c++0x standard: among the implemented features the rvalue reference. By means of the rvalue reference it should be possible to move a non-copyable object or return it from a function. Are std::streams already movable by means of rvalue reference or does the current library implementation lack...
I'm learning C++ and writing little programs as I go along. The following is one such program: // This program is intended to take any integer and convert to the // corresponding signed char. #include <iostream> int main() { signed char sch = 0; int n = 0; while(true){ std::cin >> n; sch = n; std::cout << n << " -->...
I've always wondered why the C++ Standard library has instantiated basic_[io]stream and all its variants using the char type instead of the unsigned char type. char means (depending on whether it is signed or not) you can have overflow and underflow for operations like get(), which will lead to implementation-defined value of the variabl...
I am trying to run a DataTable through an XSL tranform and then put the results back into a DataTable. My DataTable is coming up empty. Any help would be great. Dim finalExelList As New DataTable Dim xlsMyList = New XPath.XPathDocument(New StringReader(myList.DataSet.GetXml())) Dim trans As Xsl.XslCompiledTransform = New Xsl.XslCompiled...
I'm trying to read the contents of a text file, in this case a list of computer names (Computer1, computer2 etc,) and I thought that StreamReader would be what you would use but when I do the following: StreamReader arrComputer = new StreamReader(FileDialog.filename)(); I get this error: The type or namespace name 'StreamReader' coul...
Hi, The Rijndael encryption algorithm is implemented in .NET using 3 streams in the following example: Rinjdael. Can someone explain to me what these streams are doing? How/Why are they used? // Declare the streams used // to encrypt to an in memory // array of bytes. MemoryStream msEncrypt = null; CryptoStream csEncrypt = null; Stre...
Can Spirit (part of Boost C++ library) be used to parse out binary data coming from a stream? For example, can it be used to parse data coming from a socket into structures, bytes, and individual bit flags? Thanks! ...
I am implementing a very simple file database. I have 2 basic operations: void Insert(const std::string & i_record) { //create or append to the file m_fileStream.open(m_fileName.c_str(), std::ios::out | std::ios::app); if (m_fileStream.is_open()) { m_fileStream << i_record << "\n"; } m_fileStream.flush(...
Is there any way to get a specific error condition when a C++ stream open fails? That is, whether it failed because the file didn't exist, or permissions were wrong, or etc. Basically I'm looking for functionality equivalent to errno for fopen() in plain C. GCC seems to set errno properly, but that doesn't seem to be required by the C++...
If you have java.io.InputStream object how should you process that object and produce a String? Suppose I have an InputStream that contains text data, and I want to convert this to a String (for example, so I can write the contents of the stream to a log file). What is the easiest way to take the InputStream and convert it to a Strin...
I need to be able to take an arbitrary text input that may have a byte order marker (BOM) on it to mark its encoding, and output it as ASCII. We have some old tools that don't understand BOM's and I need to send them ASCII-only data. Now, I just got done writing this code and I just can't quite believe the inefficiency here. Four copies...
Is there a way to use these operators to input and output binary data? The reason I want to do this is that it makes the code readable. Ex: infile >> filedecrypter >> metadataparser >> audiodecoder >> effects >> soundplayer; ...
I have a string I need to feed to a com object that has a LoadFromStream method accepting "object Data". I'm guessing this should be a byte[]. Rather basic question: I got my MemoryStream all filled and ready to go. What's the best way to convert it to binary[]? Should I manually read it into the array one by one or is there an easy bui...
--Edit with more bgnd information-- A (black box) COM object returns me a string. A 2nd COM object expects this same string as byte[] as input and returns a byte[] with the processed data. This will be fed to a browser as downloadable, non-human-readable file that will be loaded in a client side stand-alone application. so I get the st...
I need to pull large Unicode textual strings (e.g. 200Mb) from a Database (nvarchar) and store in memory for processing. i.e. I need random access to all parts of the strings. Looking at this from strictly memory centric point of view, what are the pro’s and con’s of using a System.IO.MemoryStream versus a System.String as my in memory ...
I am a little confused here. I would like to do something like this: create some kind of buffer I can write into clear the buffer use a printf()-like function several times to append a bunch of stuff into the buffer based on some complicated calculations I only want to do once use the contents of the buffer and print it to several Pri...
I have a StreamReader object that I initialized with a stream, now I want to save this stream to disk (the stream may be a .gif or .jpg or .pdf). Existing Code: StreamReader sr = new StreamReader(myOtherObject.InputStream); I need to save this to disk (I have the filename). In the future I may want to store this to SQL Server. I h...
which method do you prefer for creating dynamic sql queries? formating or streaming? Is it just preference or there any reason one is better than other?Or any special library you use to it. EDIT: Please answer in case of c++. ...