]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/smux/value2os.h
Syntactic fixes.
[stg.git] / projects / stargazer / plugins / other / smux / value2os.h
1 #ifndef __VALUE_2_OS_H__
2 #define __VALUE_2_OS_H__
3
4 #include "stg/ObjectSyntax.h"
5
6 template <typename T>
7 bool ValueToOS(const T & value, ObjectSyntax * objectSyntax);
8
9 template <>
10 inline
11 bool ValueToOS<int>(const int & value, ObjectSyntax * objectSyntax)
12 {
13 objectSyntax->present = ObjectSyntax_PR_simple;
14 SimpleSyntax_t * simpleSyntax = &objectSyntax->choice.simple;
15 simpleSyntax->present = SimpleSyntax_PR_number;
16 asn_long2INTEGER(&simpleSyntax->choice.number, value);
17 return true;
18 }
19
20 template <>
21 inline
22 bool ValueToOS<unsigned int>(const unsigned int & value, ObjectSyntax * objectSyntax)
23 {
24 objectSyntax->present = ObjectSyntax_PR_simple;
25 SimpleSyntax_t * simpleSyntax = &objectSyntax->choice.simple;
26 simpleSyntax->present = SimpleSyntax_PR_number;
27 asn_long2INTEGER(&simpleSyntax->choice.number, value);
28 return true;
29 }
30
31 template <>
32 inline
33 bool ValueToOS<long>(const long & value, ObjectSyntax * objectSyntax)
34 {
35 objectSyntax->present = ObjectSyntax_PR_simple;
36 SimpleSyntax_t * simpleSyntax = &objectSyntax->choice.simple;
37 simpleSyntax->present = SimpleSyntax_PR_number;
38 asn_long2INTEGER(&simpleSyntax->choice.number, value);
39 return true;
40 }
41
42 template <>
43 inline
44 bool ValueToOS<unsigned long>(const unsigned long & value, ObjectSyntax * objectSyntax)
45 {
46 objectSyntax->present = ObjectSyntax_PR_simple;
47 SimpleSyntax_t * simpleSyntax = &objectSyntax->choice.simple;
48 simpleSyntax->present = SimpleSyntax_PR_number;
49 asn_long2INTEGER(&simpleSyntax->choice.number, value);
50 return true;
51 }
52
53 template <>
54 inline
55 bool 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 return true;
62 }
63
64 #endif