Go library for decoding and encoding
Real Virtuality / DayZ RAP binary config format (.bin, binary .rvmat).
- RAP decode to
rvcfgAST. - RAP encode from
rvcfgAST. - Scalar subtype handling (string / float / long) with float normalization.
- Class-body offsets and nested array support.
go get github.com/woozymasta/raprap uses github.com/woozymasta/rvcfg as text frontend:
- preprocess + parse source text into AST
- encode AST to RAP binary
- decode RAP binary back to AST/text
Parse source and encode RAP:
parsed, err := rap.ParseSourceFileWithDefaults("config.cpp")
if err != nil {
// handle
}
// or pass explicit options:
parsed, err := rap.ParseSourceFile("config.cpp", rap.SourceParseOptions{
Preprocess: rvcfg.PreprocessOptions{
IncludeDirs: []string{"./include"},
},
Parse: rvcfg.ParseOptions{
CaptureScalarRaw: true,
},
})
if err != nil {
// handle
}
bin, err := rap.EncodeAST(parsed.Processed.Parse.File, rap.EncodeOptions{})Encode RAP directly from in-memory source ([]byte):
bin, err := rap.EncodeBytesWithDefaults(
"config.cpp",
[]byte(`class CfgPatches { class TestMod { units[] = {}; }; };`),
)
if err != nil {
// handle
}Decode RAP to AST:
file, err := rap.DecodeToAST(data, rap.DecodeOptions{})
if err != nil {
// handle
}
_ = file.StatementsDecode RAP to text:
text, err := rap.DecodeToText(data, rap.DecodeOptions{}, rap.RenderOptions{
Format: rvcfg.FormatOptions{
MaxLineWidth: 120,
},
})Decode RAP from file path:
file, err := rap.DecodeFile("config.bin", rap.DecodeOptions{})
text, err := rap.DecodeFileToText("config.bin", rap.DecodeOptions{}, rap.RenderOptions{})rap.DecodeOptions{
DisableFloatNormalization: false, // default: shortest stable float32 text
}Implemented RAP entry types:
0class with body offset1scalar assignment with float value2array assignment with int32 value3extern class4delete5array append (+=)6scalar assignment with int64 value