本文整理汇总了C++中CObjectTypeInfo类的典型用法代码示例。如果您正苦于以下问题:C++ CObjectTypeInfo类的具体用法?C++ CObjectTypeInfo怎么用?C++ CObjectTypeInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CObjectTypeInfo类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
// Create some ASN.1 data that can be parsed by this code sample.
char asn[] = "Date-std ::= { year 1998, month 1, day 2, season \"winter\" }";
// Setup an input stream, based on the sample ASN.1.
CNcbiIstrstream iss(asn);
unique_ptr<CObjectIStream> in(CObjectIStream::Open(eSerial_AsnText, iss));
////////////////////////////////////////////////////
// Create a hook for the 'year' class member of Date-std objects.
// The year class member was aribtrarily chosen to illustrate the
// use of hooks - many other entities would work equally well.
// Get data structures that model the type information for Date-std
// objects and their 'year' class members.
// The type information will be used to recognize and forward 'year'
// class members of Date-std objects found in the stream to the hook.
CObjectTypeInfo stdInfo = CType<CDate_std>();
CObjectTypeInfoMI memberInfo = stdInfo.FindMember("year");
// Set a local hook for Date-std 'year' class members. This involves
// creating an instance of the hook class and passing that hook to the
// "set hook" method, which registers the hook to be called when a hooked
// type is encountered in the stream.
memberInfo.SetLocalReadHook(*in, new CReadCMHook_Date_std__year());
// Read from the input stream, storing data in the object. At this point,
// the hook is in place so simply reading from the input stream will
// cause the hook to be triggered whenever the 'year' class member is
// encountered.
in->Read(stdInfo);
return 0;
}
示例2: CopyObject
virtual void CopyObject(CObjectStreamCopier& copier,
const CObjectTypeInfo& passed_info)
{
cout << copier.In().GetStackPath() << endl;
#if 1
DefaultCopy(copier, passed_info);
#else
#if 1
// or skip the object
copier.In().SkipObject(passed_info.GetTypeInfo());
#endif
#if 0
// or read object
CSeq_annot annot;
copier.In().ReadObject(&annot, CSeq_annot::GetTypeInfo());
cout << MSerial_AsnText << annot << endl;
// and maybe write it as well
copier.Out().WriteObject(&annot, CSeq_annot::GetTypeInfo());
#endif
#if 0
// or read object and write it
CObjectInfo oi(passed_info.GetTypeInfo());
copier.In().ReadObject(oi);
copier.Out().WriteObject(oi);
#endif
// typeinfo of the object (Seq-annot)
TTypeInfo ti = passed_info.GetTypeInfo();
#endif
}
示例3:
CObjectHookGuardBase::CObjectHookGuardBase(const CObjectTypeInfo& info,
CCopyObjectHook& hook,
CObjectStreamCopier* stream)
: m_Hook(&hook),
m_HookMode(eHook_Copy),
m_HookType(eHook_Object)
{
m_Stream.m_Copier = stream;
if ( stream ) {
info.SetLocalCopyHook(*stream, &hook);
}
else {
info.SetGlobalCopyHook(&hook);
}
}
示例4: m_Hook
CObjectHookGuardBase::CObjectHookGuardBase(const CObjectTypeInfo& info,
const string& id,
CSkipChoiceVariantHook& hook,
CObjectIStream* stream)
: m_Hook(&hook),
m_HookMode(eHook_Skip),
m_HookType(eHook_Variant),
m_Id(id)
{
m_Stream.m_IStream = stream;
CObjectTypeInfoVI variant = info.FindVariant(id);
if ( stream ) {
variant.SetLocalSkipHook(*stream, &hook);
}
}
示例5: Reset
void CSoapMessage::Read(CObjectIStream& in)
{
Reset();
CSoapEnvelope env;
CObjectTypeInfo typeH = CType<CSoapHeader>();
typeH.SetLocalReadHook(in, new CSoapReadHook(m_Header,m_Types));
CObjectTypeInfo typeB = CType<CSoapBody>();
typeB.SetLocalReadHook(in, new CSoapReadHook(m_Body,m_Types));
CObjectTypeInfo typeF = CType<CSoapFault::C_Detail>();
typeF.SetLocalReadHook(in, new CSoapReadHook(m_FaultDetail,m_Types));
in >> env;
x_Check(env);
x_VerifyFaultObj(false);
}
示例6: DefaultSkip
void CSkipObjectHook::DefaultSkip(CObjectIStream& in,
const CObjectTypeInfo& type)
{
type.GetTypeInfo()->DefaultSkipData(in);
}
示例7: Match
static bool Match(const CObjectTypeInfo& type, TTypeInfo typeInfo)
{
return type.GetTypeInfo()->IsType(typeInfo);
}
示例8: DefaultCopy
void CCopyObjectHook::DefaultCopy(CObjectStreamCopier& copier,
const CObjectTypeInfo& type)
{
type.GetTypeInfo()->DefaultCopyData(copier);
}
示例9: h
void CSoapMessage::Write(CObjectOStream& out) const
{
CObjectOStreamXml* os = 0;
bool schema = false, loc = false;
string ns_default;
ESerialDataFormat fmt = out.GetDataFormat();
if (fmt == eSerial_Xml) {
os = dynamic_cast<CObjectOStreamXml*>(&out);
if (os) {
schema = os->GetReferenceSchema();
os->SetReferenceSchema();
loc = os->GetUseSchemaLocation();
os->SetUseSchemaLocation(false);
ns_default = os->GetDefaultSchemaNamespace();
os->SetDefaultSchemaNamespace(GetSoapNamespace());
}
}
CSoapEnvelope env;
if (!m_Header.empty()) {
// This is to make the stream think the Header was not empty.
// Since Header is optional, we do not have to make it *always*
CRef<CAnyContentObject> h(new CAnyContentObject);
env.SetHeader().SetAnyContent().push_back(h);
}
// This is to make the stream think the Body was not empty.
// Body is mandatory
CRef<CAnyContentObject> h(new CAnyContentObject);
env.SetBody().SetAnyContent().push_back(h);
CSoapFault* flt = 0;
if (!m_FaultDetail.empty()) {
// This is to make the stream think the Detail was not empty.
// Since Detail is optional, we do not have to make it *always*
flt = dynamic_cast<CSoapFault*>(const_cast<CSerialObject*>(
GetSerialObject("Fault", eMsgBody).GetPointer()));
if (!flt) {
// throw exception here (?)
} else {
CRef<CAnyContentObject> h2(new CAnyContentObject);
flt->SetDetail().SetAnyContent().push_back(h2);
}
}
CObjectTypeInfo typeH = CType<CSoapHeader>();
typeH.SetLocalWriteHook(out, new CSoapWriteHook(m_Header));
CObjectTypeInfo typeB = CType<CSoapBody>();
typeB.SetLocalWriteHook(out, new CSoapWriteHook(m_Body));
CObjectTypeInfo typeF = CType<CSoapFault::C_Detail>();
typeF.SetLocalWriteHook(out, new CSoapWriteHook(m_FaultDetail));
x_VerifyFaultObj(true);
out << env;
x_VerifyFaultObj(false);
if (flt) {
flt->SetDetail().SetAnyContent().clear();
}
if (os) {
os->SetReferenceSchema(schema);
os->SetUseSchemaLocation(loc);
os->SetDefaultSchemaNamespace(ns_default);
}
}
示例10: switch
void CObjectHookGuardBase::ResetHook(const CObjectTypeInfo& info)
{
switch (m_HookType) {
case eHook_Object:
switch (m_HookMode) {
case eHook_Read:
if ( m_Stream.m_IStream ) {
info.ResetLocalReadHook(*m_Stream.m_IStream);
}
else {
info.ResetGlobalReadHook();
}
break;
case eHook_Write:
if ( m_Stream.m_OStream ) {
info.ResetLocalWriteHook(*m_Stream.m_OStream);
}
else {
info.ResetGlobalWriteHook();
}
break;
case eHook_Skip:
if ( m_Stream.m_IStream ) {
info.ResetLocalSkipHook(*m_Stream.m_IStream);
}
break;
case eHook_Copy:
if ( m_Stream.m_Copier ) {
info.ResetLocalCopyHook(*m_Stream.m_Copier);
}
else {
info.ResetGlobalCopyHook();
}
break;
default:
break;
}
break;
case eHook_Member:
{
CObjectTypeInfoMI member = info.FindMember(m_Id);
switch (m_HookMode) {
case eHook_Read:
if ( m_Stream.m_IStream ) {
member.ResetLocalReadHook(*m_Stream.m_IStream);
}
else {
member.ResetGlobalReadHook();
}
break;
case eHook_Write:
if ( m_Stream.m_OStream ) {
member.ResetLocalWriteHook(*m_Stream.m_OStream);
}
else {
member.ResetGlobalWriteHook();
}
break;
case eHook_Skip:
if ( m_Stream.m_IStream ) {
member.ResetLocalSkipHook(*m_Stream.m_IStream);
}
break;
case eHook_Copy:
if ( m_Stream.m_Copier ) {
member.ResetLocalCopyHook(*m_Stream.m_Copier);
}
else {
member.ResetGlobalCopyHook();
}
break;
default:
break;
}
break;
}
case eHook_Variant:
{
CObjectTypeInfoVI variant = info.FindVariant(m_Id);
switch (m_HookMode) {
case eHook_Read:
if ( m_Stream.m_IStream ) {
variant.ResetLocalReadHook(*m_Stream.m_IStream);
}
else {
variant.ResetGlobalReadHook();
}
break;
case eHook_Write:
if ( m_Stream.m_OStream ) {
variant.ResetLocalWriteHook(*m_Stream.m_OStream);
}
else {
variant.ResetGlobalWriteHook();
}
break;
case eHook_Skip:
if ( m_Stream.m_IStream ) {
variant.ResetLocalSkipHook(*m_Stream.m_IStream);
}
//.........这里部分代码省略.........