Serialization is the process by which an object is converted into a format that can be stored and later retrieved.
4
votes
0answers
28 views
Packing and unpacking bits
I wrote this class for packing data.
Would it benefit from being named BitPacker rather than BitStream (and change write/read to pack/unpack), or it works as is?
How can I improve it? Any way to ...
2
votes
1answer
38 views
Encoding a list of frequencies as WAV audio
This code gets a list of signals with predefined frequency from struc.num
I need to encode it to wave format, so i use this code. This works, but i dont sure it is a correct decision to encode like ...
5
votes
1answer
46 views
7
votes
2answers
167 views
Reading binary files in XTF format
I have a few thousand binary files that have corresponding structs in them, followed by any number of bytes (this exact number of bytes is given in one of the fields in the structs). I read in data ...
2
votes
0answers
114 views
Binary protocol variability V3.0
Summary: Parsing an incoming stream of events from a binary communication protocol, if we have some variations in devices to support and would not like to have one huge switch to include everything.
...
3
votes
1answer
39 views
Save/Load GridView layout using SettingsService
I am able to save my GridView layout by storing a string representation of the items in the ...
4
votes
2answers
159 views
Binary protocol variability V2.0
Up-to-date Version of this question: Binary protocol variability V3.0
Summary of the problem: Parsing an incoming stream of events from a binary communication protocol, if we have some variations in ...
3
votes
3answers
316 views
Binary protocol variability
Please note: An updated solution is here
Let’s imagine that we designed more or less universal firmware for a microcontroller unit to be used across multiple types of devices. So we have something ...
0
votes
2answers
140 views
Returning a byte array from a method [closed]
public abstract class Element
{
// Removed for verbosity ...
protected abstract byte[] GetBytes();
}
I'm attempting to create an engine that can create a ...
1
vote
0answers
34 views
.NET List Serializer design
A few weeks back I wrote a class to help serialize/deserialize objects file. The file format requested was json, then compressed. After some coding/testing I settled on this design:
...
3
votes
1answer
44 views
Serialize and deserialize n dimensional int array
I've made two symmetric methods which serialize an int array of any number of dimensions into an OutputStream, and read such an array from an InputStream. I was wondering if there is ways this code ...
2
votes
0answers
32 views
Class for serializing generic gson objects
I realized I had just created two classes that were virtually identical for simply saving objects to their own json files, so I've attempted to make it more generic. My only noticeable problem is ...
4
votes
1answer
43 views
LEB128 in Haskell
I have implemented the LEB128 encoding for unsigned integers. I'm fairly new to Haskell so I have some doubt about the coding style I'm using, particularly the definition of ...
4
votes
1answer
91 views
How to separate data from logic when serializing types - grid tile map example
I am creating a tile based game in Unity and ran into a problem with my architecture of the Map and Tile types. The tile class contains logic like events when the tile type changes. When I tried to ...
3
votes
1answer
81 views
Serializing objects to delimited files
For a new project I'm going to need to be able to serialize random types to TSV or CSV files, so I write a class which can be used to serialize any object to a TSV, CSV or any other _SV file you can ...
2
votes
3answers
106 views
Code Smell in Unit Testing Serialized Classes
I can feel that something is wrong with my code. Here's an excerpt where I think the code smell is...
...
1
vote
3answers
46 views
Byte array to floating point such as FPE2 in Java
Apple's System Management Controller uses FPE2 and SP78 as floating-point formats.
While writing a Java library that that interfaces with the SMC, I ported someone's C function to convert read a FPE2-...
1
vote
1answer
53 views
6
votes
0answers
58 views
Data marshaling wrapper for a TCP server
After a lot of research, I created this wrapper which I think fits very well to my needs. My project is a TCP server and I will be using this wrapper every time the server receives a packet. Basically,...
2
votes
2answers
61 views
Generated serialization code
CGbR project
I am currently working on a project that generates code from classes. The idea is to achieve maximum performance by replacing reflection use cases with fast, generated code.
Current ...
3
votes
1answer
42 views
Something to store any (standard) data in python
I decided to try make my own way to save normal python data yesterday after coming across the minecraft NBT format, it's more limited than cPickle but appears to produce shorter results and so far ...
0
votes
1answer
76 views
Create Xml to string serializer
I don't want to serialize everything. I created a custom attribute DoNotSerializeAttribute. If some property in info contain ...
1
vote
1answer
48 views
Object parser in C++
Consider the following contrived data type:
Building: int age, char* location, float ...
1
vote
0answers
99 views
Saving the state of a ViewModel
I've the following scenario, I've got some viewmodel that need to persist their state on disk.
I've defined a custom attribute as:
...
3
votes
1answer
54 views
Vigenère cipher as an IO filter
I implemented a Vigenere encoding and decoding class. Ideally, the program should be able to take any abritrary file, read into an array of byte, and decode it.
...
2
votes
1answer
145 views
A Dynamic CSV Serializer
I made a dynamic CSV serializer as a learning challenge a while back, I'm hoping to get my code picked apart so I can learn what I can do better.
This is a bit long, so I wouldn't expect anyone to ...
6
votes
1answer
99 views
Reading bytes from packet
I have a device I connect to on TCP socket. I send it a message with what I want and it sends back all sorts of useful information:
Header:
...
1
vote
0answers
476 views
Reusable REST service class for Angular2 in TypeScript
I am creating an Angular 2 web application using TypeScript. This application performs REST requests to a REST "service". For each REST resource in my service I create a separate "Service" class in ...
0
votes
1answer
47 views
Reading many kinds of numbers from a byte buffer
I've been trying to find a way to collapse all these methods into one.
Current I have these methods
...
5
votes
1answer
55 views
Polymorphic TLV serialization
Inspired by this question I decided to write an alternative that uses polymorhphism and a Factory pattern. The code works for the subset of implemented types, namely ...
6
votes
1answer
317 views
TLV implementation in C++
I tried implementing TLV(https://en.wikipedia.org/wiki/Type-length-value).
Actually my implementation is more than TLV because it supports additional "Tag" elements (which you can use for naming ...
6
votes
2answers
984 views
Type to byte array conversion in Swift
I need the byte representation of a given type, especially double, float, int8, etc.
...
7
votes
2answers
59 views
Querying Facebook for details of a user's OAuth token
This class exposes the public method getAuthToken which takes a user's Facebook OAuth token as an input parameter and queries Facebook for information about it - ...
7
votes
2answers
76 views
Updating resources while avoiding race conditions
I am writing a utility class for a game client. This class has two main functions: connect to a game server and retrieve the current game revision, and retrieve a "recipe", which is basically ...
5
votes
3answers
63 views
Advanced formatting with argument passing
I want to customise how my objects are printed using the .format() function.
I have two problems to make that happen in clear and concise way. But since the second ...
4
votes
3answers
570 views
Format of hexeditor
Is there a cleaner way to write this code? It's the start of a hexeditor I'm creating.
I'm aware that the variables aren't descriptive, this is just a test run for when I imbed it into a File ...
4
votes
1answer
40 views
Which loop to use for multiple if statements which serialize objects
I have figured out how to serialize multiple objects, however I am utterly convinced I can use some kind of loop for the if statements below, to avoid duplication. Please can someone advise how I ...
3
votes
1answer
63 views
Serializing multiple objects to a file
I am very new to Java and although my code works, I know that it must be possible to write this using fewer lines of code. I am serializing multiple objects, eventually I will look into serializing to ...
1
vote
1answer
50 views
Dynamic CSV Formatter
I made a dynamic CSV formatter as a personal challenge after having to hardcode a behavior to convert some data to CSV earlier. You input any List that contains supported types as properties (all ...
2
votes
0answers
76 views
Generic methods for serializing and deserialzing xml files using streams followup
Recently I asked this question: Generic methods for serializing and deserialzing xml files using streams
However it has come to my attention that this gives me an (harmless) exception when trying to ...
5
votes
2answers
142 views
1
vote
1answer
33 views
WebService --> XML Cache Repository
I'm working on a small application that uses a WebService to get meta-data about television episodes. What I'd like to do is start building out a local cache of the series so that I can reduce the ...
5
votes
6answers
156 views
__repr__ for a binary tree whose constructor has default arguments
I recently have been working on a BinaryTree class, and looked into creating a proper __repr__ which when eval'ed would recreate ...
1
vote
0answers
56 views
Better way to deep copy than this? How can I make it generic by `Collection` type?
Could I make this method for deep copy generic to the Collection type?
That method is so simple and I can't imagine ever needing to change it, so maybe I should ...
1
vote
1answer
76 views
Pool readers and streams with Json.NET
This code is built on Json.NET and gets called hundreds of times per second. My data starts in an ArraySegment<byte>. I wrap that in a ...
11
votes
7answers
646 views
Numbers to byte-arrays and back
As the title explains, this is a series of extension methods that convert certain numeric types to and from byte-arrays, for certain actions which work better on byte-array types than numeric types.
...
2
votes
1answer
51 views
Three ways to read a number for a BitInputStream
I'm trying to learn how to write more readable code without introducing easily avoidable performance killers.
This is part of a BitInputStream Java class I'm ...
3
votes
1answer
445 views
Little/Big Endian conversion
I wanted to make sure that my code is properly converting between the two endians.
Here is the code where I read in an integer:
...
7
votes
2answers
654 views
Converting a SecureString to a byte array
Does it allocates something that hasn't freed? Something that remains in memory? Except result byte array, ofc.
...
1
vote
1answer
164 views
Re-use of read/write object , for multiple objects
I have read a lot about serialization and I cannot figure out how I am able to serialize then deserialize multiple objects. I am very much a newb to Java, so please bear with me.
My code currently ...