📄 conversion.cpp
字号:
#include "Conversion.h"
#include "ConversionHelper.h"
#pragma warning(disable : 4996)
// Constructor
IConversion::IConversion(const string& name) : name_(name)
{
conversionHelper_ = ConversionHelper::Instance();
conversionHelper_->Add(this);
}
IConversion::~IConversion()
{
conversionHelper_->Remove(this);
}
bool String2Object(Double* object, string& value)
{
bool result = false;
if (!object
) return result
;
object->Object() = atof(value.c_str())
;
result = true
;
return result;
}
bool String2Object(Int* object, string& value)
{
bool result = false;
if (!object
) return result
;
object->Object() = atoi(value.c_str())
;
result = true
;
return result;
}
bool String2Object(Long* object, string& value)
{
bool result = false;
if (!object
) return result
;
object->Object() = atoi(value.c_str())
;
result = true
;
return result;
}
bool String2Object(String* object, string& value)
{
bool result = false;
if (!object
) return result
;
object->Object() = value
;
result = true
;
return result;
}
bool String2Object(Bool* object, string& value)
{
bool result = false;
if (!object
) return result
;
object->Object() = (!stricmp(value.c_str(),"true")) ? true : false;
;
result = true
;
return result;
}
string Object2String(Double* object)
{
char textBuffer [256];
string result = "";
if (!object
) return result
;
sprintf (textBuffer,"%g",object->Object())
;
result = textBuffer;
return result;
}
string Object2String(Int* object)
{
char textBuffer [256];
string result = "";
if (!object
) return result
;
result = itoa(object->Object(),textBuffer,10)
;
return result;
}
string Object2String (Long* object)
{
char textBuffer [256];
string result = "";
if (!object
) return result
;
result = itoa(object->Object(),textBuffer,10)
;
return result;
}
string Object2String(Bool* object)
{
string result = "";
if (!object
) return result
;
result = object->Object() ? "true" : "false"
;
return result;
}
string Object2String (String* object)
{
string result = "";
if (!object
) return result
;
result = object->Object()
;
return result;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -