本文整理汇总了C++中IObject::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ IObject::GetType方法的具体用法?C++ IObject::GetType怎么用?C++ IObject::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObject
的用法示例。
在下文中一共展示了IObject::GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void VM::actAssert(myListStack::const_iterator& it,
myListStack::const_iterator& end,
VMStack& stack)
{
IObject *op;
if (stack.size() < 1)
return;
std::cout << "[assert] ";
while (++it != end)
{
op = Factory::makeNumber(*it);
try
{
if (op->ToString() != stack.back()->ToString())
throw 1;
if (op->GetType() != stack.back()->GetType())
throw 2;
}
catch (int e)
{
std::cout << "The value on top of the stack does "
<< "not equal the operand." << std::endl;
if (e == 1)
std::cout << " -> " << op->ToString() << " <> "
<< stack.back()->ToString() << std::endl;
else if (e == 2)
std::cout << " -> " << op->GetType() << " <> "
<< stack.back()->GetType() << std::endl;
exit(-1);
}
}
std::cout << "Good test" << std::endl;
}
示例2: GenerateSchema
std::string CCMSDIntegrator::GenerateSchema(std::string schema)
{
std::stringstream buffer;
std::string table;
buffer << "CREATE SCHEMA IF NOT EXISTS `" << schema << "` DEFAULT CHARACTER SET latin1;" << std::endl;
buffer << "USE "<< schema << ";" << std::endl ;
schema="`"+schema+"`";
buffer << std::endl << std::endl ;
buffer << "DROP TABLE IF EXISTS " << schema << "." << "Properties" << ";" << std::endl;
buffer << "CREATE TABLE IF NOT EXISTS " << schema << "." << "Properties" << "(" << std::endl;
buffer << "identifier CHAR(255) NOT NULL,";
buffer << "name CHAR(255) NOT NULL DEFAULT '',";
buffer << "value NOT NULL DEFAULT '', ";
buffer << "units CHAR(255) NULL DEFAULT '',";
buffer << "description NULL DEFAULT '',";
buffer << std::endl << "PRIMARY KEY (`identifier`)" << std::endl;
buffer << ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" << std::endl;
std::vector<IObject::CreatorFcn> & creators = IObject::GetAllCreators();
for(int j=0; j< creators.size(); j++)
{
IObject::CreatorFcn fcn = creators[j];
//Part * apart = (Part*) new Part();
IObject * apart = fcn();
table=apart->GetClassname(); // "`Part`";
buffer << std::endl << std::endl;
buffer << "-- -----------------------------------------------------" << std::endl;
buffer << "-- Table " << schema << "." << table << std::endl;
buffer << "-- -----------------------------------------------------" << std::endl;
buffer << "DROP TABLE IF EXISTS "<< schema << "." << table << ";" << std::endl;
buffer << "CREATE TABLE IF NOT EXISTS "<< schema << "." << table << "(" << std::endl;
std::vector<std::string> fields = apart->GetHeaders();
for(int i=0; i< fields.size(); i++)
{
MetaType type = apart->GetType(i);
std::string field = fields[i];
ReplaceAll(field,".", "_");
buffer << "`" << field << "` " << GetDDLType(type ) << " " ;
buffer << (( fields[i]=="identifier")? "NOT NULL " : "NULL ");
buffer << GetDDLDefault(type );
if((i+1)!=fields.size()) buffer << ", " << std::endl;
}
if(std::find(fields.begin(), fields.end(), "identifier")!=fields.end())
buffer << ", " << std::endl << "PRIMARY KEY (`identifier`)" << std::endl;
buffer << ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" << std::endl;
}
return buffer.str();
}
示例3: GetValueRaw
void DataNode::GetValueRaw(IObject& object) const
{
struct helper
{
static void ReadObject(void* object, const ObjectType& type, const DataNode& node)
{
for (auto baseType : type.GetBaseTypes())
{
const ObjectType* baseObjectType = dynamic_cast<const ObjectType*>(baseType.type);
if (!baseObjectType)
continue;
void* baseObject = (*baseType.dynamicCastUpFunc)(object);
ReadObject(baseObject, *baseObjectType, node);
}
for (auto field : type.GetFields())
{
auto srlzAttribute = field->GetAttribute<SerializableAttribute>();
if (srlzAttribute)
{
auto fldNode = node.GetNode(field->GetName());
if (fldNode)
field->DeserializeFromObject(object, *fldNode);
}
}
}
};
const ObjectType& type = dynamic_cast<const ObjectType&>(object.GetType());
void* objectPtr = type.DynamicCastFromIObject(const_cast<IObject*>(&object));
helper::ReadObject(objectPtr, type, *this);
if (object.GetType().IsBasedOn(TypeOf(ISerializable)))
((ISerializable&)object).OnDeserialized(*this);
}
示例4: GetValueDelta
void DataNode::GetValueDelta(IObject& object, const IObject& source) const
{
struct helper
{
static void ReadObject(void* object, void* source, const ObjectType& type, const DataNode& node)
{
for (auto baseType : type.GetBaseTypes())
{
const ObjectType* baseObjectType = dynamic_cast<const ObjectType*>(baseType.type);
if (!baseObjectType)
continue;
void* baseObject = (*baseType.dynamicCastUpFunc)(object);
void* baseSourceObject = (*baseType.dynamicCastUpFunc)(source);
ReadObject(baseObject, baseSourceObject, *baseObjectType, node);
}
for (auto field : type.GetFields())
{
if (!field->GetAttribute<SerializableAttribute>())
continue;
auto fldNode = node.GetNode(field->GetName());
if (fldNode)
{
if (field->GetType()->IsBasedOn(TypeOf(IObject)))
{
bool usedConverter = false;
for (auto conv : mDataConverters)
{
if (conv->IsConvertsType(field->GetType()))
{
conv->FromData(field->GetValuePtr(object), node);
usedConverter = true;
break;
}
}
if (usedConverter)
continue;
fldNode->GetValueDelta(*(IObject*)field->GetValuePtr(object),
*(IObject*)field->GetValuePtr(source));
}
else field->DeserializeFromObject(object, *fldNode);
}
else field->CopyValue(object, source);
}
}
};
if (!object.GetType().IsBasedOn(source.GetType()) && !source.GetType().IsBasedOn(object.GetType()))
{
GetValue(object);
return;
}
const ObjectType& type = dynamic_cast<const ObjectType&>(object.GetType());
void* objectPtr = type.DynamicCastFromIObject(const_cast<IObject*>(&object));
void* sourcePtr = type.DynamicCastFromIObject(const_cast<IObject*>(&source));
helper::ReadObject(objectPtr, sourcePtr, type, *this);
if (object.GetType().IsBasedOn(TypeOf(ISerializable)))
((ISerializable&)object).OnDeserialized(*this);
}