我有以下两种方法(如你所见)在大多数语句中都是类似的,除了一种(详见下文)
unsigned int CSWX::getLineParameters(const SURFACE & surface, vector<double> & params)
{
VARIANT varParams;
surface->getPlaneParams(varParams); // this is the line of code that is different
SafeDoubleArray sdParams(varParams);
for( int i = 0 ; i < sdParams.getSize() ; ++i )
{
params.push_back(sdParams[i]);
}
if( params.size() > 0 ) return 0;
return 1;
}
unsigned int CSWX::getPlaneParameters(const CURVE & curve, vector<double> & params)
{
VARIANT varParams;
curve->get_LineParams(varParams); // this is the line of code that is different
SafeDoubleArray sdParams(varParams);
for( int i = …Run Code Online (Sandbox Code Playgroud) 我目前使用以下模板作为检查NULL指针的方法,如果为NULL则将错误消息打印到日志文件然后返回false.
template< typename T >
static bool isnull(T * t, std::string name = "")
{
_ASSERTE( t != 0 );
if( !t )
{
if( !(name.length()) ) name = "pointer";
PANTHEIOS_TRACE_ERROR(name + " is NULL");
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
我现在称之为:
if( !(isnull(dim, BOOST_STRINGIZE(dim))) ) return false;
Run Code Online (Sandbox Code Playgroud)
如果你注意到我需要将我要打印的指针变量的"名称"传递给日志文件,作为第二个参数.我目前正在使用BOOST_STRINGIZE,它只是将括号内的任何文本转换为字符串.
以下是我的模板实现的缺点(至少我的用法)
无论如何我可以自动确定第一个变量的"名称",这样我可以省略每次调用时将其作为第二个参数传入吗?
这可能是一个相当新手甚至是错误的问题所以请原谅.有没有办法比较使用Boost Graph Library创建的2个图表=>在内存中创建的1个图表和从存档中加载的第2个图表(即第2个是先前序列化的)?
我没有在BGL的文档中看到运算符==,但不确定这是否意味着我必须同时编写遍历和比较.任何指向教程,参考页面或示例的指针都会非常有用
在此先感谢Ganesh
我有一个VS 2005解决方案,有很多项目(大多数是DLL,1 EXE是一个CppUnit项目),我正在尝试为Pantheios记录器添加一个固定的后端DLL,以便我可以在整个过程中使用一个记录器实例解.按照以下网址中的说明操作:
我似乎有一个固定的后端DLL,支持基本的Pantheios日志记录语句log_DEBUG, log_ERROR等,甚至是跟踪API(http://www.pantheios.org/doc/html/group__group____tracing.html),例如PANTHEIOS_TRACE_NOTICE.
但我坚持前进,因为Pantheios需要"插入器"(将基本类型转换为字符串的API)(http://www.pantheios.org/doc/html/group__group____application__layer__interface____inserters.html)来处理例如int,double,float ,指针等
我不知道如何在我创建的固定后端DLL中实现这些"插入器".如果我只是从我的其他DLL中调用它们,那么我会收到如下错误:
DLLApp.obj : error LNK2019: unresolved external symbol "public: __thiscall pantheios::integer::integer(int,int)" (??0integer@pantheios@@QAE@HH@Z) referenced in function "public: void __thiscall DLLApp::DLLAppSetup(void)" (?DLLAppSetup@DLLApp@@QAEXXZ)
我不确定是否可以(并且需要)使用sourceforge.net文章中提到的.DEF导出"整数"(和其他插入器)类,或者如果我还缺少其他东西.
非常感激任何的帮助.提前致谢.
我今天刚刚开始使用Boost :: regex,而且它也是正则表达式的新手.我一直在使用"The Regulator"和Expresso来测试我的正则表达式并且对我在那里看到的东西感到满意,但转移那个正则表达式来提升,似乎并没有按照我的意愿去做.任何帮助我解决方案的指针都会受到欢迎.作为一个附带问题,是否有任何工具可以帮助我测试我的正则表达式对boost.regex?
using namespace boost;
using namespace std;
vector<string> tokenizer::to_vector_int(const string s)
{
regex re("\\d*");
vector<string> vs;
cmatch matches;
if( regex_match(s.c_str(), matches, re) ) {
MessageBox(NULL, L"Hmmm", L"", MB_OK); // it never gets here
for( unsigned int i = 1 ; i < matches.size() ; ++i ) {
string match(matches[i].first, matches[i].second);
vs.push_back(match);
}
}
return vs;
}
void _uttokenizer::test_to_vector_int()
{
vector<string> __vi = tokenizer::to_vector_int("0<br/>1");
for( int i = 0 ; i < __vi.size() ; ++i ) INFO(__vi[i]);
CPPUNIT_ASSERT_EQUAL(2, …Run Code Online (Sandbox Code Playgroud) 我有以下C++代码(简化版):
class Shape
{
bool isCircle = false;
bool isSquare = false;
}
class Circle : public Shape
{
// some special members/methods
}
class Square : public Shape
{
// some special members/methods
}
class CAD
{
virtual DrawCircle(Circle * circle) = 0;
}
class SWX : public CAD
{
virtual DrawCircle(Circle * circle){// do some stuff that draws circle on SWX system}
}
class PRO : public CAD
{
virtual DrawCircle(Circle * circle){// do some stuff that draws …Run Code Online (Sandbox Code Playgroud)