[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
comment class feature; VC6 namespace bug workaround
From: |
Kyle Schaffrick |
Subject: |
comment class feature; VC6 namespace bug workaround |
Date: |
Thu, 18 Apr 2002 17:40:35 -0400 |
I thought I would contribute a small feature/bug fix that made my life a
bit easier. It is in regards to the comment class, specifically:
cout << b("Some text in bold"); // works
cout << comment("Some text in a comment"); // does not work
I fixed it as follows, in HTMLClasses.h:
--------------------------
/*! \class comment HTMLGeneric.h cgicc/HTMLGeneric.h
* \brief An HTML comment
*/
class comment : public HTMLBooleanElement<nullTag>
{
+public:
+ comment() { }
+ comment(const STDNS string& text)
+ : HTMLBooleanElement<nullTag>(text)
+ { }
+private:
virtual void render(STDNS ostream& out) const
{
if(getData().empty() && dataSpecified() == false) {
swapState();
out << (getState() ? "<!-- " : " -->");
---------------------------
Secondly, there is a problem with the Standard C++ Library
implementation in Microsoft Visual C++ 6.0. Some of the stdc++ headers
which are supposed to include standard C headers under the namespace std
apparently do not do their job, and simply include the symbols from
those headers in the global namespace, causing the errors
CgiInput.cpp(55) : error C2039: 'getenv' : is not a member of 'std'
CgiInput.cpp(55) : error C2440: 'initializing' : cannot convert from
'[string]' to 'char *'
I think this is a bug, considering this is counter to the MSDN
documentation of these headers. The problem is well known to me, and is
also illustrated by the fact that a file containing only
#include <cstdlib>
using namespace std;
causes a "'std' is not a namespace" error. Those having problems with
this on the help-cgicc list, I got the same error that you did on the
first go.
The following resolves this issue, from CgiInput.cpp:
----------------------------
STDNS string
CGICCNS CgiInput::getenv(const char *varName)
{
char *var =
// MSVC C++ 6.0 lib problem, <cstdlib> is not in std namespace
#if defined(_MSC_VER) && _MSC_VER < 1201 // hopefully they get it right
next time
STDNS
#else // don't call the member function
::
#endif
getenv(varName);
return (var == 0) ? "" : var;
}
-----------------------------
It's messy but portable. The conditional might also need to be tweaked,
depending on if this bug occurs in prior versions of VC++.
I hope these small improvements are of use!
-- kyle
- comment class feature; VC6 namespace bug workaround,
Kyle Schaffrick <=