T
_TR
I love C# and I've been porting a lot of my older C++ code, but there
is one app that I haven't quite figured out yet. I suppose I could
re-engineer the app from the ground up, but I've already accumulated a
lot of data files, so the format is set for now.
Basically, the data format consists of inlined Structs of different
types and lengths. I can decode the first byte to tell what type of
struct it is, then point a struct pointer to it to decode the
following bytes. The format is fairly easy to work with, and again I
already have megabytes of files in that format, so I don't want to
change it yet.
For speed, I read the entire file into RAM ahead of time rather than
paging it from disk.
Here's the question: How well would that approach translate to C#?
Someone claimed that there was no need for 'unsafe' code, given that
memory streams could be used to read the bytes into structs, but this
seems to require additional work (loading the structs as opposed to
simply pointing a *struct directly into the stream). Is there a
graceful way around this?
The fallback plan is to use VS2005's CLI/C++. I find C++'s syntax
tedious compared to C#, but the new CLI pointer mechanisms might be
preferable; I don't want the GC moving streams at awkward moments
(I'm trying to maintain good realtime response).
Any thoughts?
is one app that I haven't quite figured out yet. I suppose I could
re-engineer the app from the ground up, but I've already accumulated a
lot of data files, so the format is set for now.
Basically, the data format consists of inlined Structs of different
types and lengths. I can decode the first byte to tell what type of
struct it is, then point a struct pointer to it to decode the
following bytes. The format is fairly easy to work with, and again I
already have megabytes of files in that format, so I don't want to
change it yet.
For speed, I read the entire file into RAM ahead of time rather than
paging it from disk.
Here's the question: How well would that approach translate to C#?
Someone claimed that there was no need for 'unsafe' code, given that
memory streams could be used to read the bytes into structs, but this
seems to require additional work (loading the structs as opposed to
simply pointing a *struct directly into the stream). Is there a
graceful way around this?
The fallback plan is to use VS2005's CLI/C++. I find C++'s syntax
tedious compared to C#, but the new CLI pointer mechanisms might be
preferable; I don't want the GC moving streams at awkward moments
(I'm trying to maintain good realtime response).
Any thoughts?