本文整理汇总了C++中CObjectOStream类的典型用法代码示例。如果您正苦于以下问题:C++ CObjectOStream类的具体用法?C++ CObjectOStream怎么用?C++ CObjectOStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CObjectOStream类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
CObjectOStream* CObjectOStream::Open(ESerialDataFormat format,
CNcbiOstream& outStream,
EOwnership edeleteStream,
TSerial_Format_Flags formatFlags)
{
CObjectOStream* os = NULL;
bool deleteStream = edeleteStream == eTakeOwnership;
switch ( format ) {
case eSerial_AsnText:
os = OpenObjectOStreamAsn(outStream, deleteStream);
break;
case eSerial_AsnBinary:
os = OpenObjectOStreamAsnBinary(outStream, deleteStream);
break;
case eSerial_Xml:
os = OpenObjectOStreamXml(outStream, deleteStream);
break;
case eSerial_Json:
os = OpenObjectOStreamJson(outStream, deleteStream);
break;
default:
break;
}
if (os != NULL) {
os->SetFormattingFlags(formatFlags);
return os;
}
NCBI_THROW(CSerialException,eNotImplemented,
"CObjectOStream::Open: unsupported format");
}
示例2: WriteChoiceDefault
void CChoiceTypeInfoFunctions::WriteChoiceDefault(CObjectOStream& out,
TTypeInfo objectType,
TConstObjectPtr objectPtr)
{
const CChoiceTypeInfo* choiceType =
CTypeConverter<CChoiceTypeInfo>::SafeCast(objectType);
BEGIN_OBJECT_FRAME_OF3(out, eFrameChoice, choiceType, objectPtr);
out.BeginChoice(choiceType);
TMemberIndex index = choiceType->GetVariants().FirstIndex();
const CVariantInfo* variantInfo = choiceType->GetVariantInfo(index);
if (variantInfo->GetId().IsAttlist()) {
const CMemberInfo* memberInfo =
dynamic_cast<const CMemberInfo*>(
choiceType->GetVariants().GetItemInfo(index));
memberInfo->WriteMember(out,objectPtr);
}
index = choiceType->GetIndex(objectPtr);
if ( index == kInvalidMember )
out.ThrowError(out.fInvalidData, "cannot write empty choice");
variantInfo = choiceType->GetVariantInfo(index);
BEGIN_OBJECT_FRAME_OF2(out, eFrameChoiceVariant, variantInfo->GetId());
out.BeginChoiceVariant(choiceType, variantInfo->GetId());
variantInfo->WriteVariant(out, objectPtr);
out.EndChoiceVariant();
END_OBJECT_FRAME_OF(out);
out.EndChoice();
END_OBJECT_FRAME_OF(out);
}
示例3: Write
static void Write(CObjectOStream& out, TTypeInfo ,
TConstObjectPtr objectPtr)
{
if ( objectPtr != 0 ) {
out.ThrowError(out.fInvalidData,
"non-null value when writing NULL member");
}
out.WriteNull();
}
示例4: SetLastError
CRef< CTaxon3_reply >
CTaxon3::SendRequest(const CTaxon3_request& request)
{
SetLastError(NULL);
unsigned reconnect_attempts = 0;
while (reconnect_attempts < m_nReconnectAttempts) {
try {
auto_ptr<CObjectOStream> pOut;
auto_ptr<CObjectIStream> pIn;
auto_ptr<CConn_ServiceStream>
pServer( new CConn_ServiceStream(m_sService, fSERV_Any,
0, 0, m_timeout) );
pOut.reset( CObjectOStream::Open(m_eDataFormat, *pServer) );
pIn.reset( CObjectIStream::Open(m_eDataFormat, *pServer) );
CObjectIStream* ppIn = pIn.release();
CObjectOStream* ppOut = pOut.release();
try {
*ppOut << request;
ppOut->Flush();
ppOut->Close();
try {
CRef< CTaxon3_reply > response(new CTaxon3_reply);
*ppIn >> *response;
delete ppIn;
delete ppOut;
return response;
} catch (exception& e) {
SetLastError( e.what() );
}
} catch (exception& e) {
SetLastError( e.what() );
}
} catch( exception& e ) {
SetLastError( e.what() );
}
reconnect_attempts++;
}
// return NULL
CRef<CTaxon3_reply> reply;
return reply;
}
示例5: WriteAliasDefault
void CAliasTypeInfoFunctions::WriteAliasDefault(CObjectOStream& out,
TTypeInfo objectType,
TConstObjectPtr objectPtr)
{
const CAliasTypeInfo* aliasType =
CTypeConverter<CAliasTypeInfo>::SafeCast(objectType);
out.WriteAlias(aliasType, objectPtr);
}
示例6: WriteContainer
void CContainerTypeInfo::WriteContainer(CObjectOStream& out,
TTypeInfo objectType,
TConstObjectPtr objectPtr)
{
const CContainerTypeInfo* containerType =
CTypeConverter<CContainerTypeInfo>::SafeCast(objectType);
out.WriteContainer(containerType, objectPtr);
}
示例7: WritePointer
void CPointerTypeInfo::WritePointer(CObjectOStream& out,
TTypeInfo objectType,
TConstObjectPtr objectPtr)
{
const CPointerTypeInfo* pointerType =
CTypeConverter<CPointerTypeInfo>::SafeCast(objectType);
out.WritePointer(pointerType->GetObjectPointer(objectPtr),
pointerType->GetPointedType());
}
示例8: Write
void Write(CObjectOStream& out, TConstObjectPtr object, TTypeInfo type)
{
out.Write(object, type);
}
示例9: 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);
}
}
示例10: CustomWrite
void CWriteChoiceVariantHook::CustomWrite(CObjectOStream& out,
const CConstObjectInfoCV& variant, const CConstObjectInfo& custom_object)
{
out.WriteExternalObject(custom_object.GetObjectPtr(), variant.GetVariantInfo()->GetTypeInfo());
}
示例11: DefaultWrite
void CWriteChoiceVariantHook::DefaultWrite(CObjectOStream& out,
const CConstObjectInfoCV& variant)
{
out.WriteChoiceVariant(variant);
}