473,320 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Serializing a data buffer from C++

I am relatively new to C# and .Net in general, but have been programming in
many other languages for more years than I want to recall.

I have a problem where an existing set of code (actually a Windows kernel
component developed by a company I do some work for) is returning
information to user space in the buffer from an IOCTL call in a 'streaming'
format that mixes variable length strings, 8-, 16-, 32-, and 64-bit integer
values. The code currently adds NULL bytes to force some alignment just to
keep some other code happy, but this can easily be removed if not needed.
The buffer contains some fixed header fields followed by zero or more 'rows'
or records, which are each variable length due to the fact that they contain
variable length strings.

<ReportID>
<ContextID>
<Record Count>
<More?>
NULL

<Record Length>
<String Data>
NULL
NULL

<Integer Value>
<Integer Value>

<Timestamp>

<String Data>
NULL
NULL
NULL

<IntegerValue>
<Record Length
<String Data>

<continued>

<continued>
NULL

<Integer Value>
<Integer Value>

<Timestamp>

<String Data>

<continued>

<continued>
NULL

<Integer Value>
NULL
NULL
NULL
NULL

I basically want to extract this information field by field and then use the
information to populate a DataSet, making the rows of data look like
information retrieved as if from a database query. I asked some people about
this and they indicated that serialization was the proper approach, but I am
not certain if I follow this.

Do I have to create two (2) classes, one for the header information and one
for the row data, and make each serializable?

The problem that I see is that the serialization process adds contextual
information for each data value being written serialized and the deserializa
tion process requires this information to be present in the stream that is
being read. All of the methods used to retrieve fields from the
SerializationInfo structure seem to require that I identify the field
information in some manner, which implies that this may be some sort of XML
object rather than a raw binary stream.

In my case all that I have is raw data! Presuming that all I have is a
buffer address for the beginning of the buffer above, how can I extract the
individual fields and then use them? I am will to create a class to hold the
retrieved values, but I would then need to use a different offset into the
buffer for each instance of these class objects.

-Ken
Nov 16 '05 #1
0 2103

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Aleksei Guzev | last post by:
Imagine one writing a class library CL1 for data storage. He defines classes ‘DataItem’ and ‘DataRecord’ so that the latter contains a collection of the former. And he derives class ‘IntItem’ from...
10
by: copx | last post by:
I want to save a struct to disk.... as plain text. At the moment I do it with a function that just writes the data using fprintf. I mean like this: fprintf(fp, "%d %d", my_struct.a, my_struct.b)...
5
by: Alfonso Morra | last post by:
Hi, I am writing a messaging library which will allow me to send a generic message structure with custom "payloads". In many cases, a message must store a non-linear data structure (i.e....
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
0
by: Ken Allen | last post by:
I am relatively new to C# and .Net in general, but have been programming in many other languages for more years than I want to recall. I have a problem where an existing set of code (actually a...
6
by: Marco Herrn | last post by:
Hi, I need to serialize an object into a string representation to store it into a database. So the SOAPFormatter seems to be the right formatter for this purpose. Now I have the problem that...
0
by: olsonchris | last post by:
Hello all, I have what appears to be a simple question but after quite a bit of research I can't seem to find an answer. Basically, I am serializing a class into an XML document. This is...
6
by: Kyle Teague | last post by:
What would give better performance, serializing a multidimensional array and storing it in a single entry in a table or storing each element of the array in a separate table and associating the...
5
by: | last post by:
I've got a basic "chat" infrastructure that can send objects across the wire, but I'm running into a few issues with trying to send multiple messages and things behaving differently in debug and...
12
by: Cagdas Ozgenc | last post by:
Greetings, When directly serializing C++ structures to a file with the standard library functions giving the address of the data and length of structure using the sizeof operator, do I risk...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.