comp.lang.c++@googlegroups.com | Google Groups | ![]() |
Unsure why you received this message? You previously subscribed to digests from this group, but we haven't been sending them for a while. We fixed that, but if you don't want to get these messages, send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
- Dealing with strings with NULL characters in the middle - 3 Updates
- What is g++ version of _wfreopen() and _flushall() please? - 5 Updates
- What is your preferred Linux "distro" for C++ development? - 3 Updates
- How to transfer data to another class - 2 Updates
- default argument given for parameter error - 2 Updates
- Allocating dynamically two large memory blocks next to each other. - 2 Updates
- istream - 1 Update
- Difference between data structures - 2 Updates
- C++ Books for new C++ Programmer (who is experienced in C and Python) - 1 Update
Chicken Mcnuggets <chicken@mcnuggets.com>: Nov 25 07:47PM I'm writing an SCGI server and it receives strings in this form: "70:" "CONTENT_LENGTH" <00> "27" <00> "SCGI" <00> "1" <00> "REQUEST_METHOD" <00> "POST" <00> "REQUEST_URI" <00> "/deepthought" <00> "," "What is the answer to life?" as you can see it has NULL characters separating the headers and values from each other. Using the standard constructor for std::string assumes a const char * which is a C string and therefore NULL terminated. Therefore the string is truncated at the first NULL character. There must be some way to get past this since SCGI is not an unpopular protocol. Any help is appreciated. |
Christopher Pisz <nospam@notanaddress.com>: Nov 25 02:01PM -0600 On 11/25/2014 1:47 PM, Chicken Mcnuggets wrote: > There must be some way to get past this since SCGI is not an unpopular > protocol. > Any help is appreciated. For something like this, usually the first step is to see if there is an existing library for the protocol already. I did a quick google search and there are several. Why reinvent something someone else has already done? Then it's a matter of narrowing it down by how good the documentation and examples are, if there are resources for questions, etc. If I absolute had to implement it myself, I'd treat the data as bytes rather than strings until the parts were seperated. Perhaps a std::vector<char> contains the received data. Then you search for delims, like NULLs in this case, and seperate out the specific part. You'd probably want a class structure for the entire response and some map of name and values inside. I don't know anything about the scgi protocol though. |
Paavo Helde <myfirstname@osa.pri.ee>: Nov 25 02:05PM -0600 Chicken Mcnuggets <chicken@mcnuggets.com> wrote in news:w15dw.1498$fi4.67 > as you can see it has NULL characters separating the headers and values > from each other. Using the standard constructor for std::string assumes > a const char * which is a C string and therefore NULL terminated. This is just a convenience constructor. There are other constructors for std::string which also take the string length. There is no problem with embedded zero bytes in std::string, it's a character like any other as far as std::string is concerned. Cheers Paavo |
Hongliang Wang <loudking@gmail.com>: Nov 24 09:48PM -0800 Hi all, Could anybody tell me if g++ has a wide char support version of freopen() and _flushall() function? Thanks. |
jt@toerring.de (Jens Thoms Toerring): Nov 25 02:08PM > Could anybody tell me if g++ has a wide char support version of > freopen() and _flushall() function? It's not a question about g++ but about the C library you're using with it, so a hopefully correct answer can only be "it depends". If the library is the GNU C library (glibc) then it supports a non-standard addition to the mode string for fopen() and freopen(), ",ccs=string", where, citing from the man page: "'string' is taken as the name of a coded character set and the stream is marked as wide-oriented." There's no _flushall() function in glibc I've ever heard of, this seems to be something Microsoft invented. Use fflush() with a NULL pointer to flush all open *output* files - it shouldn't matter if the file was opened with wide char sup- port or not. Note that this only flushes the internal buf- fers of the (GNU) C libraray, if you have to ensure that the data are physically written to disk (as far as that is pos- ible) you'll have to do an additional call of sync(). Regards, Jens -- \ Jens Thoms Toerring ___ jt@toerring.de \__________________________ http://toerring.de |
Christopher Pisz <nospam@notanaddress.com>: Nov 25 10:16AM -0600 On 11/24/2014 11:48 PM, Hongliang Wang wrote: > Hi all, > Could anybody tell me if g++ has a wide char support version of freopen() and _flushall() function? Thanks. Why not program in C++ using std::wfstream ? |
"Öö Tiib" <ootiib@hot.ee>: Nov 25 10:44AM -0800 On Tuesday, 25 November 2014 18:16:38 UTC+2, Christopher Pisz wrote: > > Hi all, > > Could anybody tell me if g++ has a wide char support version of freopen() and _flushall() function? Thanks. > Why not program in C++ using std::wfstream ? Perhaps because the difference between 'freopen' and '_wfreopen' is only if *file* *names* and *modes* are given as wide character strings or character strings (L"dick.jpeg" or "dick.jpeg"). Otherwise it is a 'FILE*' that you get from both. 'wfstream::open' and 'fstream::open' however both take 'char*' or 'std::string' as file name and the difference is in character types that are streamed in those *text* streams (not too suitable for neither L"dick.jpeg" or "dick.jpeg"). So the issue is in different place sort of. ;-) |
Christopher Pisz <nospam@notanaddress.com>: Nov 25 01:20PM -0600 On 11/25/2014 12:44 PM, 嘱 Tiib wrote: > types that are streamed in those *text* streams (not too suitable > for neither L"dick.jpeg" or "dick.jpeg"). So the issue is in different > place sort of. ;-) Perhaps, but one would have to question why they'd have a project in which they were giving parameters as wide strings, but not dealing with the data as wide strings. Furthermore, I'd suspect one would wish to receive the contents of a .jpeg file as bytes rather than text :P |
me <noone@all.net>: Nov 25 05:09AM On Sun, 12 Oct 2014 13:13:02 -0500, Robert Hutchings wrote: > Some people strongly prefer Slackware.... I've been a Fedora guy since about FC8. For what I do I need the bleeding edge packages. ------------------------- SuperMicro SuperServer 2 * 2.4ghz quad-core Westmere CPUs 24GB RAM 8 * 1TB disks configured in 2 software raid5 volumes nVidia GTX460 40inch Samsung 1080p monitor original IBM Model-M "clicky" keyboard Hey! It heats my house in the winter. LOL |
me <noone@all.net>: Nov 25 05:12AM On Sun, 12 Oct 2014 14:15:37 -0700, woodbrian77 wrote: > now wish I had switched earlier. Better late than never. > Brian Ebenezer Enterprises - So far G-d has helped us. > http://webEbenezer.net Back in the late 90s and early 2000s I was exclusively a BSDi (commercial BSD) guy. Then when Linux started to become stable, around kernel 2.4.x, I started using Linux exclusively again. |
Chicken Mcnuggets <chicken@mcnuggets.com>: Nov 25 11:39AM On 25/11/14 05:09, me wrote: >> Some people strongly prefer Slackware.... > I've been a Fedora guy since about FC8. For what I do I need the > bleeding edge packages. Then why not use Gentoo or Arch Linux? Both really do have bleeding edge packages. I'm an Arch Linux guy myself and love it. Everything works if you configure it correctly. It is extremely fast on my machine (even though I don't have it installed on an SSD) and all the dev tools such as compilers, profilers and debuggers are always up to date. Plus running the latest stable kernel and having the latest glibc at all times helps when you want to test out new features in Linux. Overall I don't see why someone wouldn't use Arch Linux on the desktop. Servers are a different matter and for that I prefer either OpenBSD or the Ubuntu LTS releases (because they have a well defined support life cycle). |
fl <rxjwg98@gmail.com>: Nov 24 10:37PM -0800 Hi, I have a question about transferring data from a class to another. Today, I see the following line: We can use a class object for transferring data to another class. from a forum. But I do not have a clue on how to get it in C++. Could you explain it to me, especially by an example? Thanks, |
Ian Collins <ian-news@hotmail.com>: Nov 25 07:56PM +1300 fl wrote: > We can use a class object for transferring data to another class. > from a forum. But I do not have a clue on how to get it in C++. Could > you explain it to me, especially by an example? Please wrap your lines! Some context would help. -- Ian Collins |
me <noone@all.net>: Nov 25 02:09AM On Fri, 03 Oct 2014 15:47:17 -0700, zwei1000vier10 wrote: > Googling i found that puting the def. value both in the header AND the > implementation file is what's usually causing this error. > I hope i wake up to a solution.... thank you Default argument values go in the function declaration, not in the implementation. That's just the way it is. Might have something to do with the header file being where people look to see how a function is declared. Makes sense to put default argument values there. |
Robert Wessel <robertwessel2@yahoo.com>: Nov 25 12:53AM -0600 >implementation. That's just the way it is. Might have something to do >with the header file being where people look to see how a function is >declared. Makes sense to put default argument values there. Well, it needs to be in the declaration, since the compiler needs it to compile a call with a default parameter (and it may well not be able to see the implementation at the time of the call's compilation). |
me <noone@all.net>: Nov 25 04:54AM On Fri, 17 Oct 2014 18:56:26 -0700, pkoniusz wrote: > from 2x50GB continuous memory blocks. > Thanks in advance, > Pete Replace new and delete with custom versions that do whatever memory management your heart desires. |
mad-crapper <madcrapper@toilet.com>: Nov 25 04:55AM On Tue, 25 Nov 2014 04:54:43 +0000, me wrote: > On Fri, 17 Oct 2014 18:56:26 -0700, pkoniusz wrote: > Replace new and delete with custom versions that do whatever memory > management your heart desires. And by replace I mean override. :) |
me <noone@all.net>: Nov 25 02:23AM On Wed, 08 Oct 2014 12:28:41 -0700, Mark wrote: > std::streamsize const streamLen > = iss.rdbuf()->in_avail(); > But streamLen is always zero. As others have pointed out, istream has no concept of size. Streams just flow and flow and flow. You will need to wrap it in something to add the requested functionality yourself, and handle errors and exceptions accordingly. |
Christopher Pisz <nospam@notanaddress.com>: Nov 24 05:47PM -0600 On 11/24/2014 3:43 PM, K' Dash wrote: > What are the main differences between Vector an Map? One of them is an associative container and one isn't. One guarantees contiguous memory and the other doesn't. |
legalize+jeeves@mail.xmission.com (Richard): Nov 25 02:19AM [Please do not mail me a copy of your followup] "K' Dash" <adnanrashidpk@gmail.com> spake the secret code >What are the main differences between Vector an Map? <http://en.cppreference.com/w/> -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
legalize+jeeves@mail.xmission.com (Richard): Nov 25 02:17AM [Please do not mail me a copy of your followup] Jorgen Grahn <grahn+nntp@snipabacken.se> spake the secret code >Fair enough, but templates can just as well make the code /more/ >readable. Saying the same thing many times in slightly different ways >can (like you say) be really distracting. Agreed. As others on this thread have said, don't use language features just for the sake of using them. Use language features to enhance the readability and expressiveness of your code. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment