当前位置: 首页>>代码示例>>C++>>正文


C++ CObjectOStream::GetDataFormat方法代码示例

本文整理汇总了C++中CObjectOStream::GetDataFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ CObjectOStream::GetDataFormat方法的具体用法?C++ CObjectOStream::GetDataFormat怎么用?C++ CObjectOStream::GetDataFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CObjectOStream的用法示例。


在下文中一共展示了CObjectOStream::GetDataFormat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Write

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);
    }
}
开发者ID:svn2github,项目名称:ncbi_tk,代码行数:68,代码来源:soap_message.cpp


注:本文中的CObjectOStream::GetDataFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。