]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/smux/value2os.h
Update README.
[stg.git] / projects / stargazer / plugins / other / smux / value2os.h
1 #pragma once
2
3 #pragma GCC diagnostic push
4 #pragma GCC diagnostic ignored "-Wold-style-cast"
5 #include "stg/ObjectSyntax.h"
6 #pragma GCC diagnostic pop
7
8 #include <string>
9
10 template <typename T>
11 void ValueToOS(const T & value, ObjectSyntax * objectSyntax);
12
13 template <>
14 inline
15 void ValueToOS<int>(const int & value, ObjectSyntax * objectSyntax)
16 {
17 objectSyntax->present = ObjectSyntax_PR_simple;
18 SimpleSyntax_t * simpleSyntax = &objectSyntax->choice.simple;
19 simpleSyntax->present = SimpleSyntax_PR_number;
20 asn_long2INTEGER(&simpleSyntax->choice.number, value);
21 }
22
23 template <>
24 inline
25 void ValueToOS<unsigned int>(const unsigned int & value, ObjectSyntax * objectSyntax)
26 {
27 objectSyntax->present = ObjectSyntax_PR_simple;
28 SimpleSyntax_t * simpleSyntax = &objectSyntax->choice.simple;
29 simpleSyntax->present = SimpleSyntax_PR_number;
30 asn_long2INTEGER(&simpleSyntax->choice.number, value);
31 }
32
33 template <>
34 inline
35 void ValueToOS<long>(const long & value, ObjectSyntax * objectSyntax)
36 {
37 objectSyntax->present = ObjectSyntax_PR_simple;
38 SimpleSyntax_t * simpleSyntax = &objectSyntax->choice.simple;
39 simpleSyntax->present = SimpleSyntax_PR_number;
40 asn_long2INTEGER(&simpleSyntax->choice.number, value);
41 }
42
43 template <>
44 inline
45 void ValueToOS<unsigned long>(const unsigned long & value, ObjectSyntax * objectSyntax)
46 {
47 objectSyntax->present = ObjectSyntax_PR_simple;
48 SimpleSyntax_t * simpleSyntax = &objectSyntax->choice.simple;
49 simpleSyntax->present = SimpleSyntax_PR_number;
50 asn_long2INTEGER(&simpleSyntax->choice.number, value);
51 }
52
53 template <>
54 inline
55 void ValueToOS<std::string>(const std::string & value, ObjectSyntax * objectSyntax)
56 {
57 objectSyntax->present = ObjectSyntax_PR_simple;
58 SimpleSyntax_t * simpleSyntax = &objectSyntax->choice.simple;
59 simpleSyntax->present = SimpleSyntax_PR_string;
60 OCTET_STRING_fromBuf(&simpleSyntax->choice.string, value.c_str(), static_cast<int>(value.length()));
61 }