This code can be found in the [archive here][1]archive here. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.
Removed raise functions from above code. [1]: http://webEbenezer.net/build_integration.html
This code can be found in the [archive here][1]. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.
Removed raise functions from above code. [1]: http://webEbenezer.net/build_integration.html
This code can be found in the archive here. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.
Removed raise functions from above code.
This code can be found in the archive here [archive here][1]. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.
#ifndef CMW_ErrorWords_hh
#define CMW_ErrorWords_hh
#include <exception>
#include <string>
namespace cmw {
class failure : public ::std::exception {
::std::string whatStr;
public:
explicit failure (char const* what_) : whatStr(what_)
{}
explicit failure (::std::string what_) : whatStr(::std::move(what_))
{}
~failure () throw()
{}
char const* what () const throw()
{ return whatStr.c_str(); }
failure& operator<< (char* s)
{
whatStr.append(s);
return *this;
}
failure& operator<< (char const* s)
{
whatStr.append(s);
return *this;
}
failure& operator<< (::std::string const& s)
{
whatStr.append(s);
return *this;
}
template <class T>
failure& operator<< (T const& val)
{
whatStr.append(::std::to_string(val));
return *this;
}
};
class eof : public failure {
public:
explicit eof (char const* what_) : failure(what_)
{}
~eof () throw()
{}
template <class T>
eof& operator<< (T val)
{
failure::operator<<(val);
return *this;
}
};
inline void raise (failure const& ex)
{
throw ex;
}
inline void raise (eof const& ex)
{
throw ex;
}
}
#endif
Oo Tiib suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.
Edit 2:
Removed raise functions from above code. [1]: http://webEbenezer.net/build_integration.html
This code can be found in the archive here. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.
#ifndef CMW_ErrorWords_hh
#define CMW_ErrorWords_hh
#include <exception>
#include <string>
namespace cmw {
class failure : public ::std::exception {
::std::string whatStr;
public:
explicit failure (char const* what_) : whatStr(what_)
{}
explicit failure (::std::string what_) : whatStr(::std::move(what_))
{}
~failure () throw()
{}
char const* what () const throw()
{ return whatStr.c_str(); }
failure& operator<< (char* s)
{
whatStr.append(s);
return *this;
}
failure& operator<< (char const* s)
{
whatStr.append(s);
return *this;
}
failure& operator<< (::std::string const& s)
{
whatStr.append(s);
return *this;
}
template <class T>
failure& operator<< (T const& val)
{
whatStr.append(::std::to_string(val));
return *this;
}
};
class eof : public failure {
public:
explicit eof (char const* what_) : failure(what_)
{}
~eof () throw()
{}
template <class T>
eof& operator<< (T val)
{
failure::operator<<(val);
return *this;
}
};
inline void raise (failure const& ex)
{
throw ex;
}
inline void raise (eof const& ex)
{
throw ex;
}
}
#endif
Oo Tiib suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.
This code can be found in the [archive here][1]. Usually I have a .cc file, but in this case it's all in a header. Am wondering about that. It needs to work in VS12. If possible I'll post more code from the archive for review. I started with this because it's used a lot. Tia.
#ifndef CMW_ErrorWords_hh
#define CMW_ErrorWords_hh
#include <exception>
#include <string>
namespace cmw {
class failure : public ::std::exception {
::std::string whatStr;
public:
explicit failure (char const* what_) : whatStr(what_)
{}
explicit failure (::std::string what_) : whatStr(::std::move(what_))
{}
~failure () throw()
{}
char const* what () const throw()
{ return whatStr.c_str(); }
failure& operator<< (char* s)
{
whatStr.append(s);
return *this;
}
failure& operator<< (char const* s)
{
whatStr.append(s);
return *this;
}
failure& operator<< (::std::string const& s)
{
whatStr.append(s);
return *this;
}
template <class T>
failure& operator<< (T const& val)
{
whatStr.append(::std::to_string(val));
return *this;
}
};
class eof : public failure {
public:
explicit eof (char const* what_) : failure(what_)
{}
~eof () throw()
{}
template <class T>
eof& operator<< (T val)
{
failure::operator<<(val);
return *this;
}
};
}
#endif
Oo Tiib suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.
Edit 2:
Removed raise functions from above code. [1]: http://webEbenezer.net/build_integration.html
SomeoneOo Tiib suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.
Someone suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.
Oo Tiib suggested the raise function as a help for debugging -- a central function where you could put a breakpoint to see the stack. It may be something used in some large projects. That made some sense so I decided to try it. I believe I need both versions of raise to avoid slicing.