how to convert flatbuffer .fbs file to .bin file - flatbuffers

i am learning flatbuffers in java
I want to create a .bin file from .fbs file and I don't have .json file already how do i create a json file so that I can create a bin file?
as they already had mosterdata.json file in thier sample code but what if we don't have the JSON file? and we just had the .fbs file and it's generated java code only?
as mentioned here how will i get the data file ?

There are two ways to make your .bin file.
Use JSON to specify the contents.
flatc -b <your_schema.fbs> <your_data.json>
Where -b means generate a binary file.
To make your_data.json you'll have to make it yourself, using your_schema.fbs to guide you on how to specify the json fields. I would check out how the monsterdata_test.json is specified by its corresponding schema monster_test.fbs
Use flatc to output the Java code gen, and then programmatically generate the .bin using the generated code.
flatc --java <your_schema.fbs>
This way is a lot more involved, since you have to make a program that uses the generated code and output the binary yourself. Check out the tutorial (switch to the java language) for example usage.

Related

How to inject data in a .bin file in a post compilation script?

Purpose
I want my build system to produce one binary file that includes:
The bootloader
The application binary
The application header (for the bootloader)
Here's a small overview of the memory layout (nothing out of the ordinary here)
The build system already concatenates the bootloader and the application in a post-compilation script.
In other words, only the header is missing.
Problem
What's the best way to generate and inject the application header in the memory?
Possible solutions
Create a .bin file just for the header and use cat to inject it in my final binary
Use linker file to hardcode the header (is this possible?)
Use a script to read the final binary and hardcode the header
Other?
What is the best solution for injecting data in memory in a post compilation script?
SRecord is a great tool for doing all kinds of manipulation on binary and other file types used for embedded code images.
In this case, given a binary bootheader.bin to insert at offset 0x8000 in image.bin:
srec_cat bootheader.bin −binary −offset 0x8000 −o image.bin
The tool is somewhat arcane, but the documentaton includes numerous examples covering various common tasks.

How to read/edit Parasoft SOATEST .tst file by code or manually?

I need to read the .txt file as raw text or by code to extract the data keyed in the test suite (resource/assertors,....). Is there any way to do that? by code or any editor.
If you have binary format of tst file then there could be a problem, there is no official API to read it.
It's very old format, I don't think that is still in use.
There could be also two, newest, formats of tst:
compressed XML
XML
In case of compressed XML you have to unzip it and then you have access to XML, where you can read it as text file.
In case of XML, it's just XML, you can read it as pure text file.
There is no official API which allows to read it in similar way as SOAtest's GUI to use in code i.e.: in Java.

Can we make Spoon's output follow the same directory path as the original?

For now, Spoon's directory structure of output will follow the package path written in *.java file. In fact, there are many other files even *.java files, whose real file paths are different from package paths.
So, my Spoon's output folder was disordered.
In short the answer for this question is: no.
Spoon uses standard Java organization to process output files, meaning: each Java file is output in its package hierarchy as it should be done for source files (see: https://docs.oracle.com/javase/tutorial/java/package/managingfiles.html).
However if your problem is related to file created because of inner classes: you could solve it using the following option:
[--output-type ]
States how to print the processed source code:
nooutput|classes|compilationunits (default: classes)
with value "compilationunits".
Finally if it's really an issue for you, don't hesitate to propose a new feature through a pull request on the Github repository!

Read file to variable in Visual Basic

I want to be able to put a file to a variable so I can interact with it. For example I could put a wav file into a variable and play it back without having to distribute the separate file. Is this possible for instance by using Base64. I have seen some Python programs for example that have images embedded in the code.
Yes, you could conceivably store the contents of a binary .wav file as a static, uuencoded text array.
Probably a better way to go about it would be to create a "resource" for your binary data:
http://msdn.microsoft.com/en-us/library/xbx3z216.aspx

Objective C - Accessing files in zip without extracting zip

I'm looking for a way to access files within a zip file without extracting the whole file. All the zip solutions I find on the internet seems to extract the whole zip. Does anyone know of a solution?
Google has an objective-c lib based on minizip. http://code.google.com/p/objective-zip/
Supports unzip of individual files
EDIT: the project has moved to GitHub
The zlib library source distribution comes with a 'contrib' directory. In it, you'll find a library called 'minizip' (same license as zlib itself), which has APIs for creating (zip.h) and navigating/extracting (unzip.h) ZIP files. Despite the filename, there are functions in unzip.h which let you list or search for files within the zip file without extracting it.
If the zip is up on the internet you can have a look at pinch which will let you extract individual files from the zip without downloading the whole file.
https://github.com/epatel/pinch-objc
Maybe you can use it as a base to extract individual files from a local zip archive.