473,378 Members | 1,122 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Choosing between a Null stream and ostringstream

#define LOG(level) \
(level > Log::CurrentLevel() ? NullStream(): Log().Get(level))

struct NullStream:std::ostream {
public:
NullStream():std::ios(0), std::ostream(0){}
};

Log().Get() returns a ostringstream.

The following statement statement gives the below compiler error:
LOG(3) << "logging" << endl;


error: operands to ?: have different types ‘NullStream’ and ‘std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >’

How can I rewrite the Macro LOG?


Thanks
Naveen
Aug 28 '10 #1
1 1842
weaknessforcats
9,208 Expert Mod 8TB
What are you trying to do?

The first hint of trouble is that #define. You use those in C a lot but rarely in C++.
Aug 29 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Stewart Gordon | last post by:
Using g++ 3.1, Mac OS X. I'm doing something trying to involve a null output stream, i.e. a stream that just discards what goes into it. The idea is that it gives a simple way of producing...
2
by: Steve Gilbey | last post by:
I have a dataset from which I need to extract certain columns, format them into xml and output to an xmldocument object. From reading various posts on similar subjects, I have come up with the...
1
by: David C. allen | last post by:
I have created a simple Client-side SOAP Extension for a webclass that I have. When I apply the extension attribute to the the calling function in the proxy class I get an error 'Value cannot be...
1
by: andrewcw | last post by:
OK I am half way there - I can manipulate the stream without the byte issue like this - but is this the way to push the new values back into the stream & write out the stream without resorting to...
1
by: andrewcw | last post by:
Missing the obvious here..thanks.. I need to open the file exclusively for on entry like this: FileStream stream = null; stream = File.Open(fiPath, FileMode.Open,...
0
by: Frank Jeseit | last post by:
Hi, I call methods of my web service asynchronously. A few of my users report the exception below System.ArgumentNullException Message: value cannot be null. Parameter name: stream Source:...
7
by: Jeronimo Bertran | last post by:
Hello , I am trying to read a resource in my .net app using a stream. I found the GetMainfestResourceStream but I am having trouble using it with the resources I edit with the resource editor. ...
1
by: garyusenet | last post by:
>From MSDN I'm trying to learn more about streamreader. I'm working my way down the MSDN definition. The first entry is the Public Constructor StreamReader. I'm fairly happy I have a basic grasp on...
4
by: toton | last post by:
Hi, I want to have a log stream, where I can put certain logs. The log can be console or file or any other ui widget. This part I had already done with. However I want log stream (std::ostream...
11
by: coomberjones | last post by:
I have a few std::strings that I am using to store raw binary data, each of which may very well include null bytes at any point or points. I want to slap them together into a single string, so I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.