We stand with Ukraine
NOTE: The OSS ASN.1 Compiler generates the Time-Optimized Encoder/Decoder (TOED) by default. Prior to version 5.0, the Space Optimized Control File (SOED) was generated instead. The following command lines are equivalent:
asn1cpp asn1cpp -toed
asn1cpp input1.asn asn1cpp input1
asn1cpp input1 -noWarning asn1cpp input1 -now
asn1cpp input1 input2 -listingFile asn1cpp input1 input2 -listingFile myFile
When you specify input filenames on the command line, consider the following:
With ASN.1 Studio's intuitive user interface you can easily check any ASN.1 syntax, as well as create, edit, and view ASN.1 messages.
You can generate C++ code from the input ASN.1 syntax and add your own code that implements your application's business logic. Then you can export your ASN.1 Studio project to an ASN.1 compiler command-line file, a Visual Studio project, a makefile, or a shell script.
For details on working with ASN.1 Studio, see the Welcome page that opens when ASN.1 Studio is launched. There you'll find links to the most frequently used ASN.1 Studio Help pages, sample projects, project management operations, and to various online resources.
The maximum number of bytes in a single line of input is 4096.
1024 bytes is the maximum size of an input item such as an identifier; a type, value, or module reference; a binary string; a character string; or a hexidecimal string.
To enable support for INTEGERs having a maximum size of 4096 bytes, use the ASN1.HugeInteger or OSS.HUGE directive. Otherwise, an integer can be 2, 4, or 8 bytes long.
The OSS ASN.1 compiler interprets MAX or MIN in a constraint on an INTEGER type as the maximum or minimum value of an int in C++, which is a 4-byte integer on most machines. To extend an integer into an 8-byte integer range, specify the actual values in the constraint rather than MAX or MIN, as shown by C in the following example:
A ::= INTEGER (0..MAX) -- this will become an unsigned int B ::= INTEGER (MIN..30) -- this will become an int C ::= INTEGER (-1..3422147483647) -- this will become a long long
If the input ASN.1 uses REAL types and contains value notation with special REAL values, such as NOT-A-NUMBER or -0, then the code generated by the ASN.1/C++ compiler is not C++ compilable.
The ASN.1 Compiler supports the syntax of an open-ended value range constraint using the less than sign ("<") on REAL types. However, the runtime libraries will not enforce these constraints; any less than signs are ignored. If the open-ended constraint must be enforced use the EXCEPT clause to do so.
For example, change
A ::= REAL (0<..MAX) B ::= REAL (100<..<1000)
A ::= REAL ((0..MAX) EXCEPT 0) B ::= REAL ((100<..<1000) EXCEPT (100 | 1000))
When the -gendirectives option is used, the compiler does not generate the ASN1.Nickname or OSS.TYPENAME directive for mangled names in internal OSS type definitions, such as ObjectID, External, EmbeddedPDV, ABSTRACT_SYNTAX, and TYPE-IDENTIFIER.
The Time-Optimized encoder supports only the definite length form of BER encodings. On the other hand, the Time-Optimized decoder supports all valid BER encodings, including those in the indefinite length form.
The Time-Optimized Encoder/Decoder does not support the Canonical Encoding Rules (CER); the -cer option can only be used with the -soed option.
The Time-Optimized Encoder/Decoder does not check pattern constraints.
When C++-compiling generated TOED code, you can set C++ preprocessor macros to enable or disable various features in the result. By default, only encoding and decoding functions will be present in the compiled code. See C++ Compiler Macros to Optimize Size and Speed when Using the TOED for details.
Runtime Restrictions: Time-Optimized Encoder/Decoder
Except for REAL and UTF8String, all ASN.1 types have only one C++ representation, unless the -soed option is specified.
The REAL type is represented as a double by default. You can change its representation to OssDecimal by applying the OSS.DECIMAL directive.
Length1 ::= REAL Length2 ::= REAL --<DECIMAL>--
typedef double Length1; typedef OssDecimal Length2;
The UTF8String type can be represented as an OssString (default), an OssBMPString, or as an OssUniversalString. To obtain the OssBMPString representation, use the OSS.BMPSTRING directive; for the OssUniversalString representation, use the OSS.UNIVERSALSTRING directive.
Name1 ::= UTF8String Name2 ::= UTF8String --<UNIVERSALSTRING>-- Name3 ::= UTF8String --<BMPSTRING>--
typedef OssString Name1; typedef OssUniversalString Name2; typedef OssBMPString Name3;
The Lean encoder supports only the DEFINITE length form of BER encodings. On the other hand, the Lean decoder supports all valid BER encodings, including those that are in the INDEFINITE form.
The ASN.1 compiler does not accept the OSS.INT, OSS.LONG, or OSS.SHORT compiler directives when -lean is specified. These directives are accepted when -soed is used.
The Lean Encoder/Decoder does not support the Canonical Encoding Rules (CER); the -cer option can be used only with the -soed option.
Runtime Restrictions: Lean Encoder/Decoder
The XER/CXER/E-XER encoder/decoder does not support
The OER/COER encoder/decoder does not support the ASN1.DeferDecoding compiler directive.
ASN.1 Value Notation encoding rules (AVN) are currently supported by the TOED runtime only. The -avn compiler option is not compatible with the -soed and -lean options.
This documentation applies to release 7.2 and later of the OSS® ASN.1 Tools for C++.
Copyright © 2023 OSS Nokalva, Inc. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means electronic, mechanical, photocopying, recording or otherwise, without the prior permission of OSS Nokalva, Inc.
Every distributed copy of the OSS® ASN.1 Tools for C++ is associated with a specific license and related unique license number. That license determines, among other things, what functions of the OSS ASN.1 Tools for C++ are available to you.