Variant Streaming Code | CodeGuru

Variant Streaming Code

. Overview This code provides two global functions, WriteVariantToStream and ReadVariantFromStream, that enable you to read and write a variant to a stream. In addition, there are two other global functions, ReadVariantFromBlob and WriteVariantToBlob, for reading and writing a variant to a BLOB. Highlights Here are some of the main advantages of these functions: Uses […]

Written By
CodeGuru Staff
CodeGuru Staff
Oct 9, 2000
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

.

Overview

This code provides two global functions, WriteVariantToStream and ReadVariantFromStream,
that enable you to read and write a variant to a stream. In addition, there are two other
global functions, ReadVariantFromBlob and WriteVariantToBlob, for reading and writing
a variant to a BLOB.

Highlights

Here are some of the main advantages of these functions:

  • Uses any given IStream to stream the Variant into and out of.
  • Data is streamed in efficient binary form.
  • Stream is versioned for backwards compatibility.
  • Supports arbitrary size and arbitrary dimension safe-arrays.
  • Object streaming is supported if the object in variant supports
    IPersistStream[Init].
  • All code is in one header file (VariantStream.h) and only two routines are
    exposed: WriteVariantToStream and ReadVariantFromStream.
  • Comes with supporting test code that tests the header file — in case code
    is modified
  • Does not use C++ exception handling.  Test project has EH flag
    turned..
  • Doesn’t use the CRT.
  • Does not use any Direct-To-COM (VC++’s comdef.h, such as _variant_t, _bstr_t,
    _com_ptr, _com_error)
  • Works in both Unicode and ANSI
Advertisement

Downloads

Download source – 37 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.