本文整理汇总了C++中ObjectWrapper类的典型用法代码示例。如果您正苦于以下问题:C++ ObjectWrapper类的具体用法?C++ ObjectWrapper怎么用?C++ ObjectWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kernel_assert
void PointerMetaClass::initialize( const ObjectWrapper &obj,
InputStream* inputStream ) const {
Address address = obj.get_address();
kernel_assert(obj.get_meta_class() == this);
// debugit("initializing pointer ",address);
if ( _pre_init ) {
_pre_init( obj, true, inputStream );
}
Address objectAddress = *(Address*)address;
// test for whether it's already there
if ( _is_static ||
( _pointer_owns_object && inputStream->exists_in_input_stream( objectAddress ) &&
(!inputStream->was_already_visited( objectAddress ) ) ) ) {
if ( !_is_static ) {
inputStream->set_already_visited( objectAddress );
}
const MetaClass *mc =
get_base_type()->get_meta_class( (Byte*)objectAddress );
mc->initialize( ObjectWrapper(*(Address*)address, mc), inputStream );
}
if ( _post_init ) {
_post_init( obj, true, inputStream );
}
}
示例2:
PointerWrapper::PointerWrapper(const ObjectWrapper &obj) :
_meta_class(NULL), _address(0)
{
kernel_assert_message(is_pointer(obj),
("Attempt to pointer object with non-pointer"));
_meta_class = to<PointerMetaClass>(obj.get_meta_class());
_address = obj.get_address();
}
示例3: agg_obj
Address UnionIterator::current() const {
if (!_is_valid) return(0);
AggregateWrapper agg_obj(_address, _metaClass);
ObjectWrapper obj = _current_field_description->build_object(agg_obj);
return(obj.get_address());
// return _is_valid ? (((Byte*) _address)+_current_field_description->offset)
// : 0;
}
示例4: wrapSimpleType
bool GridClientObjectWrapperConvertor::wrapSimpleType(const GridClientVariant& var, ObjectWrapper& objWrapper) {
objWrapper.set_type(NONE);
GridClientVariantVisitorImpl visitor(objWrapper);
objWrapper.set_binary((void*) NULL, 0);
var.accept(visitor);
return objWrapper.type() != NONE;
}
示例5: return
/*
bool
SuifPrinterModule::print2(ostream& output, const ObjectWrapper &obj,
const LString &name, int _indent, int deref)
{
return(print2(output, obj.get_address(), obj.get_meta_class(),
name, _indent, deref));
}
*/
bool
//SuifPrinterModule::print2(ostream& output, const Address what, const MetaClass* type,
// //const LString &name = emptyLString, int _indent = 2, int deref = 0)
// const LString &name, int _indent, int deref)
SuifPrinterModule::print2(ostream& output, const ObjectWrapper &obj,
const LString &name, int _indent, int deref)
{
if (!start_of_object(output,obj,deref)) {
return false;
}
// MetaClassId id = type->get_meta_class_id();
String str = get_print_string(obj.get_meta_class()->get_instance_name());
// This is NOT always a suifobject. It is only
// a suifobject if the metaclass is a child of the SuifObject metaclass.
SuifObject *o = NULL;
if (is_kind_of_suif_object_meta_class(obj.get_meta_class())) {
o = (SuifObject *) obj.get_address();
}
// length is at least 1 (for the \0 at the end)
//output << "p2:deref = " << deref << endl;
if (use_print_string() && str != emptyString) {
bool b = parse_and_print(output, obj, name, str, _indent, deref);
end_of_object(output,obj);
return b;
}
// No print string registered.
const MetaClass *type = obj.get_meta_class();
bool b = false;
if (type->is_elementary()) {
b = print_elementary(output, obj, name, _indent, deref);
}
else if (type->isKindOf(AggregateMetaClass::get_class_name())) {
b = print_aggregate(output,
AggregateWrapper(obj),
name, _indent, deref);
}
else if (type->isKindOf(PointerMetaClass::get_class_name())) {
b = print_pointer(output,
PointerWrapper(obj),
name, _indent, deref);
}
else if (type->isKindOf(ListMetaClass::get_class_name())) {
b = print_list(output, obj, name, _indent, deref);
}
else if (type->isKindOf(STLMetaClass::get_class_name())) {
b = print_stl(output, obj, name, _indent, deref);
}
else {
b = print_catchall(output, obj, name, _indent, deref);
}
end_of_object(output,obj);
return b;
}
示例6: print_dispatch
void CPrintStyleModule::print_dispatch(Module *module,
ostream &str,
const ObjectWrapper &obj)
{
CPrintStyleModule *pm = (CPrintStyleModule*)module;
String result;
if (is_kind_of_suif_object_meta_class(obj.get_meta_class())) {
result = pm->print_to_string((const SuifObject*)obj.get_address());
}
str << result.c_str();
}
示例7: getUserObject
void* JavaScriptObject::getUserObject()
{
CefRefPtr<CefBase> data = m_pObject->GetUserData();
ObjectWrapper* ow = (ObjectWrapper*)data.get();
if (ow)
return ow->getData();
return NULL;
}
示例8: unwrapCollection
template<class T> void unwrapCollection(const ObjectWrapper& objWrapper, std::vector<T>& res) {
assert(objWrapper.type() == COLLECTION);
assert(objWrapper.has_binary());
res.clear();
::Collection coll;
unmarshalMsg(objWrapper.binary().c_str(), objWrapper.binary().size(), coll);
unwrapCollection(coll, res);
}
示例9: doUnwrapSimpleType
static bool doUnwrapSimpleType(const ObjectWrapper& objWrapper, GridClientVariant& var) {
assert(objWrapper.has_binary());
GG_LOG_DEBUG("Unwrap simple type: %s", objWrapper.DebugString().c_str());
string binary = objWrapper.binary();
bool unwrapRes = false;
switch (objWrapper.type()) {
case NONE:
return true;
case BOOL:
return getBoolValue(binary, var);
case BYTE:
return getByteValue(binary, var);
case BYTES:
return getBytesValue(binary, var);
case INT32:
return getInt32Value(binary, var);
case INT64:
return getInt64Value(binary, var);
case SHORT:
return getInt16Value(binary, var);
case STRING:
var.set(binary);
return true;
case DOUBLE:
return getDoubleValue(binary, var);
case FLOAT:
return getFloatValue(binary, var);
case TASK_BEAN:
return getTaskTesult(binary, var);
default: // Non-simple type
break;
}
return unwrapRes;
}
示例10: unwrapMap
template<class K, class V> void unwrapMap(ObjectWrapper objWrapper, std::map<K, V>& res) {
assert(objWrapper.type() == MAP);
assert(objWrapper.has_binary());
res.clear();
::Map map;
unmarshalMsg((int8_t*) objWrapper.binary().c_str(), objWrapper.binary().size(), map);
const ::google::protobuf::RepeatedPtrField< ::KeyValue >& repFileds = map.entry();
std::for_each(repFileds.begin(), repFileds.end(), MapInserter<K, V, ::KeyValue>(res));
}
示例11: retrieve_tag
size_t ObjectTags::retrieve_tag(const ObjectWrapper &obj)
{
TagMap::iterator iter = _tags->find(obj.get_address());
if (iter == _tags->end())
{
// (*_tags)[obj.get_address()] = _next_tag;
_tags->enter_value(obj.get_address(), _next_tag);
_next_tag++;
return(_next_tag-1);
}
else
{
return((*iter).second);
}
}
示例12: get_tag
size_t ObjectTags::get_tag(const ObjectWrapper &obj)
{
TagMap::iterator iter = _tags->find(obj.get_address());
suif_assert_message(iter != _tags->end(),
("invalid tag retrieval"));
return((*iter).second);
}
示例13: GG_LOG_DEBUG
void GridClientProtobufMarshaller::unwrap(const ObjectWrapper& objWrapper, GridClientMessageLogResult& logRslt) {
ProtoResponse resp;
GG_LOG_DEBUG("Unwrap: %s", objWrapper.DebugString().c_str());
unwrapResponse(objWrapper, resp);
GG_LOG_DEBUG("Unwrap result: %s", resp.DebugString().c_str());
fillResponseHeader(resp, logRslt);
std::vector<std::string> lines;
if (resp.has_resultbean()) {
assert(resp.resultbean().type() == COLLECTION);
const std::string& binary = resp.resultbean().binary();
::Collection coll;
unmarshalMsg((int8_t*) binary.c_str(), binary.size(), coll);
for (auto it = coll.item().begin(); it != coll.item().end(); ++it) {
const ObjectWrapper& el = (*it);
lines.push_back(el.binary());
}
}
logRslt.lines(lines);
}
示例14: destruct
void STLMetaClass::destruct( const ObjectWrapper &obj,
bool called_from_destructor ) const {
kernel_assert(obj.get_meta_class() == this);
// an stl object is never destroyed from the destructor
kernel_assert( !called_from_destructor );
_stl_descriptor->get_destructor_function()( obj );
}
示例15: obj
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool
SuifPrinterModule::print_catchall(ostream& output,
const ObjectWrapper &obj,
const LString &name,
int _indent,int deref = 0)
{
const Address what = obj.get_address();
const MetaClass* type = obj.get_meta_class();
int field_deref = deref?deref-1:0;
output << type->get_instance_name()
<< '(' << type->get_meta_class_id() << ") ";
if (name)
output << ' ' << name << ' ';
output << " (un-implemented) ";
Iterator* it = type->get_iterator(what);
if (it) {
if (it->current()) {
//output << "{\n";
output << endl;
//while (it->is_valid()) {
for (; it->is_valid(); it->next())
{
ObjectWrapper obj(it->current(), it->current_meta_class());
// const MetaClass* currentMetaClass = it->current_meta_class();
// const Address curAddr = it->current();
if(!obj.is_null()) {
// if (curAddr) {
indent(output, _indent+istep);
print2(output, obj, it->current_name(),
_indent+istep, field_deref);
}
// it->next();
//}
}// while (it->is_valid());
indent(output, _indent);
//output << "}\n";
}
else
output <<" {0x0}\n";
}
if (it) delete it;
return true;
}