473,385 Members | 1,593 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,385 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 2107

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...
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...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.