509bd584274cda3f383ae3e5856d5d22aba3b704
[ldk-java] / c_sharp / src / org / ldk / structs / ParseOrSemanticError.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8 /**
9  * Indicates that something went wrong while parsing or validating the invoice. Parsing errors
10  * should be mostly seen as opaque and are only there for debugging reasons. Semantic errors
11  * like wrong signatures, missing fields etc. could mean that someone tampered with the invoice.
12  */
13 public class ParseOrSemanticError : CommonBase {
14         protected ParseOrSemanticError(object _dummy, long ptr) : base(ptr) { }
15         ~ParseOrSemanticError() {
16                 if (ptr != 0) { bindings.ParseOrSemanticError_free(ptr); }
17         }
18
19         internal static ParseOrSemanticError constr_from_ptr(long ptr) {
20                 long raw_ty = bindings.LDKParseOrSemanticError_ty_from_ptr(ptr);
21                 switch (raw_ty) {
22                         case 0: return new ParseOrSemanticError_ParseError(ptr);
23                         case 1: return new ParseOrSemanticError_SemanticError(ptr);
24                         default:
25                                 throw new ArgumentException("Impossible enum variant");
26                 }
27         }
28
29         /** A ParseOrSemanticError of type ParseError */
30         public class ParseOrSemanticError_ParseError : ParseOrSemanticError {
31                 public ParseError parse_error;
32                 internal ParseOrSemanticError_ParseError(long ptr) : base(null, ptr) {
33                         long parse_error = bindings.LDKParseOrSemanticError_ParseError_get_parse_error(ptr);
34                         org.ldk.structs.ParseError parse_error_hu_conv = org.ldk.structs.ParseError.constr_from_ptr(parse_error);
35                         if (parse_error_hu_conv != null) { parse_error_hu_conv.ptrs_to.AddLast(this); };
36                         this.parse_error = parse_error_hu_conv;
37                 }
38         }
39         /** A ParseOrSemanticError of type SemanticError */
40         public class ParseOrSemanticError_SemanticError : ParseOrSemanticError {
41                 public SemanticError semantic_error;
42                 internal ParseOrSemanticError_SemanticError(long ptr) : base(null, ptr) {
43                         this.semantic_error = bindings.LDKParseOrSemanticError_SemanticError_get_semantic_error(ptr);
44                 }
45         }
46         internal long clone_ptr() {
47                 long ret = bindings.ParseOrSemanticError_clone_ptr(this.ptr);
48                 GC.KeepAlive(this);
49                 return ret;
50         }
51
52         /**
53          * Creates a copy of the ParseOrSemanticError
54          */
55         public ParseOrSemanticError clone() {
56                 long ret = bindings.ParseOrSemanticError_clone(this.ptr);
57                 GC.KeepAlive(this);
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 org.ldk.structs.ParseOrSemanticError ret_hu_conv = org.ldk.structs.ParseOrSemanticError.constr_from_ptr(ret);
60                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
61                 return ret_hu_conv;
62         }
63
64         /**
65          * Utility method to constructs a new ParseError-variant ParseOrSemanticError
66          */
67         public static ParseOrSemanticError parse_error(org.ldk.structs.ParseError a) {
68                 long ret = bindings.ParseOrSemanticError_parse_error(a.ptr);
69                 GC.KeepAlive(a);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 org.ldk.structs.ParseOrSemanticError ret_hu_conv = org.ldk.structs.ParseOrSemanticError.constr_from_ptr(ret);
72                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
73                 return ret_hu_conv;
74         }
75
76         /**
77          * Utility method to constructs a new SemanticError-variant ParseOrSemanticError
78          */
79         public static ParseOrSemanticError semantic_error(SemanticError a) {
80                 long ret = bindings.ParseOrSemanticError_semantic_error(a);
81                 GC.KeepAlive(a);
82                 if (ret >= 0 && ret <= 4096) { return null; }
83                 org.ldk.structs.ParseOrSemanticError ret_hu_conv = org.ldk.structs.ParseOrSemanticError.constr_from_ptr(ret);
84                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
85                 return ret_hu_conv;
86         }
87
88         /**
89          * Checks if two ParseOrSemanticErrors contain equal inner contents.
90          * This ignores pointers and is_owned flags and looks at the values in fields.
91          */
92         public bool eq(org.ldk.structs.ParseOrSemanticError b) {
93                 bool ret = bindings.ParseOrSemanticError_eq(this.ptr, b == null ? 0 : b.ptr);
94                 GC.KeepAlive(this);
95                 GC.KeepAlive(b);
96                 return ret;
97         }
98
99         public override bool Equals(object o) {
100                 if (!(o is ParseOrSemanticError)) return false;
101                 return this.eq((ParseOrSemanticError)o);
102         }
103         /**
104          * Get the string representation of a ParseOrSemanticError object
105          */
106         public string to_str() {
107                 string ret = bindings.ParseOrSemanticError_to_str(this.ptr);
108                 GC.KeepAlive(this);
109                 return ret;
110         }
111
112 }
113 } } }