use of uk.co.real_logic.sbe.xml.IrGenerator in project simple-binary-encoding by real-logic.
the class SbeTool method main.
/**
* Main entry point for the SBE Tool.
*
* @param args command line arguments. A single filename is expected.
* @throws Exception if an error occurs during process of the message schema.
*/
public static void main(final String[] args) throws Exception {
if (args.length == 0) {
System.err.format("Usage: %s <filenames>...%n", SbeTool.class.getName());
System.exit(-1);
}
for (final String fileName : args) {
final Ir ir;
if (fileName.endsWith(".xml")) {
final String xsdFilename = System.getProperty(SbeTool.VALIDATION_XSD);
if (xsdFilename != null) {
validateAgainstSchema(fileName, xsdFilename);
}
ir = new IrGenerator().generate(parseSchema(fileName), System.getProperty(TARGET_NAMESPACE));
} else if (fileName.endsWith(".sbeir")) {
ir = new IrDecoder(fileName).decode();
} else {
System.err.println("Input file format not supported: " + fileName);
System.exit(-1);
return;
}
final String outputDirName = System.getProperty(OUTPUT_DIR, ".");
if (Boolean.parseBoolean(System.getProperty(GENERATE_STUBS, "true"))) {
final String targetLanguage = System.getProperty(TARGET_LANGUAGE, "Java");
generate(ir, outputDirName, targetLanguage);
}
if (Boolean.parseBoolean(System.getProperty(GENERATE_IR, "false"))) {
final File inputFile = new File(fileName);
final String inputFilename = inputFile.getName();
final int nameEnd = inputFilename.lastIndexOf('.');
final String namePart = inputFilename.substring(0, nameEnd);
final File fullPath = new File(outputDirName, namePart + ".sbeir");
try (IrEncoder irEncoder = new IrEncoder(fullPath.getAbsolutePath(), ir)) {
irEncoder.encode();
}
}
}
}
use of uk.co.real_logic.sbe.xml.IrGenerator in project simple-binary-encoding by real-logic.
the class OtfExample method encodeSchema.
private static void encodeSchema(final ByteBuffer byteBuffer) throws Exception {
final Path path = Paths.get("src/main/resources/example-schema.xml");
try (InputStream in = new BufferedInputStream(Files.newInputStream(path))) {
final MessageSchema schema = XmlSchemaParser.parse(in, ParserOptions.DEFAULT);
final Ir ir = new IrGenerator().generate(schema);
try (IrEncoder irEncoder = new IrEncoder(byteBuffer, ir)) {
irEncoder.encode();
}
}
}
Aggregations