CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
xml_serialization_reader.h
1
2#pragma once
3#include <xml/xml_node.h>
4#include <xml/xml_element.h>
5#include <xml/xml_document.h>
6#include <xml/xml_attribute.h>
7#include <xml/i_xml_serializable.h>
8#include <system/type_info.h>
9#include <system/string.h>
10#include <system/shared_ptr.h>
11#include <system/reflection/assembly.h>
12#include <system/object.h>
13#include <system/exceptions.h>
14#include <system/date_time.h>
15#include <system/array.h>
16#include <cstdint>
17
18#include "xml/xml_reader.h"
19#include "xml/xml_qualified_name.h"
20#include "xml/xml_serializer.h"
21
22namespace System { namespace Xml { namespace Serialization {
23
24class XmlSerializer;
25
27class ASPOSECPP_SHARED_CLASS ABSTRACT XmlSerializationReader : public System::Object
28{
29 using BaseType = Object;
30
31public:
35 ASPOSECPP_SHARED_API void Initialize(System::SharedPtr<XmlReader> reader,
37
38protected:
41 ASPOSECPP_SHARED_API bool get_IsReturnValue();
42 ASPOSECPP_SHARED_API void set_IsReturnValue(bool value);
43 ASPOSECPP_SHARED_API int32_t get_ReaderCount();
44 ASPOSECPP_SHARED_API bool get_DecodeName();
45 ASPOSECPP_SHARED_API void set_DecodeName(bool value);
46
47 ASPOSECPP_SHARED_API XmlSerializationReader();
48
49 ASPOSECPP_SHARED_API void AddTarget(String id, System::SharedPtr<Object> o);
50 ASPOSECPP_SHARED_API Exception CreateCtorHasSecurityException(String typeName);
52 ASPOSECPP_SHARED_API Exception CreateAbstractTypeException(String name, String ns);
55 ASPOSECPP_SHARED_API Exception CreateUnknownConstantException(String value, const TypeInfo& enumType);
56 ASPOSECPP_SHARED_API Exception CreateUnknownNodeException();
58 ASPOSECPP_SHARED_API void CheckReaderCount(int32_t& whileIterations, int32_t& readerCount);
59
60 template <typename T>
62 {
63 if (a != nullptr && index < a->get_Length())
64 {
65 return a;
66 }
67
68 int32_t size;
69 if (a == nullptr)
70 {
71 size = 32;
72 }
73 else
74 {
75 size = a->get_Length() * 2;
76 }
77
78 System::ArrayPtr<T> result = System::MakeArray<T>(size);
79 if (a != nullptr)
80 {
81 Array<T>::Copy(a, result, index);
82 }
83
84 return result;
85 }
86
87 template <typename T>
88 System::ArrayPtr<T> ShrinkArray(System::ArrayPtr<T> a, int length, TypeInfo elementType, bool isNullable)
89 {
90 if (length == 0 && isNullable)
91 {
92 return nullptr;
93 }
94 if (a == nullptr)
95 {
96 // return Array::CreateInstance(elementType, length);
97 return System::MakeArray<T>(length);
98 }
99 if (a->get_Length() == length)
100 {
101 return a;
102 }
103
104 System::ArrayPtr<T> result = System::MakeArray<T>(length);
105 Array<T>::Copy(a, result, length);
106 return result;
107 }
108
109 ASPOSECPP_SHARED_API void FixupArrayRefs(System::SharedPtr<Object> fixup);
110 ASPOSECPP_SHARED_API int32_t GetArrayLength(String name, String ns);
111 ASPOSECPP_SHARED_API bool GetNullAttr();
114 ASPOSECPP_SHARED_API virtual void InitCallbacks() = 0;
115 ASPOSECPP_SHARED_API virtual void InitIDs() = 0;
116 ASPOSECPP_SHARED_API bool IsXmlnsAttribute(String name);
119 ASPOSECPP_SHARED_API void ReadEndElement();
120 ASPOSECPP_SHARED_API bool ReadNull();
122 ASPOSECPP_SHARED_API String ReadNullableString();
123 ASPOSECPP_SHARED_API bool ReadReference(String& fixupReference);
126 ASPOSECPP_SHARED_API void ReadReferencedElements();
127 ASPOSECPP_SHARED_API System::SharedPtr<Object> ReadReferencingElement(String& fixupReference);
129 String& fixupReference);
130 ASPOSECPP_SHARED_API System::SharedPtr<Object> ReadReferencingElement(String name, String ns, bool elementCanBeType,
131 String& fixupReference);
132 ASPOSECPP_SHARED_API System::SharedPtr<IXmlSerializable>
134 ASPOSECPP_SHARED_API System::SharedPtr<IXmlSerializable>
136 ASPOSECPP_SHARED_API String ReadString(String value);
138 ASPOSECPP_SHARED_API System::SharedPtr<XmlNode> ReadXmlNode(bool wrapped);
139 ASPOSECPP_SHARED_API System::SharedPtr<XmlDocument> ReadXmlDocument(bool wrapped);
140 ASPOSECPP_SHARED_API void Referenced(System::SharedPtr<Object> o);
141
142 ASPOSECPP_SHARED_API System::ArrayPtr<uint8_t> ToByteArrayBase64(bool isNull);
143 ASPOSECPP_SHARED_API static System::ArrayPtr<uint8_t> ToByteArrayBase64(String value);
144 ASPOSECPP_SHARED_API System::ArrayPtr<uint8_t> ToByteArrayHex(bool isNull);
145 ASPOSECPP_SHARED_API static System::ArrayPtr<uint8_t> ToByteArrayHex(String value);
146 ASPOSECPP_SHARED_API static char16_t ToChar(String value);
147 ASPOSECPP_SHARED_API static DateTime ToDate(String value);
148 ASPOSECPP_SHARED_API static DateTime ToDateTime(String value);
149 ASPOSECPP_SHARED_API static DateTime ToTime(String value);
150 ASPOSECPP_SHARED_API static String ToXmlName(String value);
151 ASPOSECPP_SHARED_API static String ToXmlNCName(String value);
152 ASPOSECPP_SHARED_API static String ToXmlNmToken(String value);
153 ASPOSECPP_SHARED_API static String ToXmlNmTokens(String value);
157 String qnames);
160 String qnames);
161 ASPOSECPP_SHARED_API void UnknownNode(System::SharedPtr<Object> o);
162 ASPOSECPP_SHARED_API void UnknownNode(System::SharedPtr<Object> o, String qnames);
163 ASPOSECPP_SHARED_API void UnreferencedObject(String id, System::SharedPtr<Object> o);
164 ASPOSECPP_SHARED_API String CollapseWhitespace(String value);
165 ASPOSECPP_SHARED_API Exception CreateBadDerivationException(String xsdDerived, String nsDerived, String xsdBase,
166 String nsBase, String clrDerived, String clrBase);
168 String id);
169 ASPOSECPP_SHARED_API Exception CreateMissingIXmlSerializableType(String name, String ns, String clrType);
170 ASPOSECPP_SHARED_API String ReadString(String value, bool trim);
172 ASPOSECPP_SHARED_API static System::SharedPtr<Reflection::Assembly> ResolveDynamicAssembly(String assemblyFullName);
173 ASPOSECPP_SHARED_API int64_t
175 String typeName);
176
177protected:
178#ifdef ASPOSE_GET_SHARED_MEMBERS
180 ASPOSECPP_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
181#endif
182
183private:
187 int32_t delayedFixupId;
188 int32_t readCount, whileIterationCount;
189 String w3SchemaNS;
190 String w3InstanceNS;
191 String w3InstanceNS2000;
192 String w3InstanceNS1999;
193 String soapNS;
194 String wsdlNS;
195 String nullX;
196 String nil;
197 String typeX;
198 String arrayType;
200
201 String CurrentTag();
202 bool TargetReady(String id);
203 bool ReadList(System::SharedPtr<Object>& resultList);
204 System::SharedPtr<Object> ReadTypedPrimitive(System::SharedPtr<XmlQualifiedName> qname, bool reportUnknown);
205 void OnUnknownNode(System::SharedPtr<XmlNode> node, System::SharedPtr<Object> o, String qnames);
206};
207
208}}} // namespace System::Xml::Serialization
static void Copy(const ArrayPtr< SrcType > &srcArray, const ArrayPtr< DstType > &dstArray, int64_t count)
Copies the specified number of elements from the source array to the destination array.
Definition: array.h:1116
Forward declaration of Dictionary class.
Definition: dictionary.h:96
Represents a specific date and time value on the time continuum. This type should be allocated on sta...
Definition: date_time.h:50
Template that represents wrapper of exceptions that are derived from Exception class.
Definition: exception.h:113
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Represents a particular type and provides information about it.
Definition: type_info.h:109
Service class improving XmlReader experience.
Definition: xml_serialization_reader.h:28
static System::ArrayPtr< uint8_t > ToByteArrayHex(String value)
System::SharedPtr< XmlQualifiedName > ToXmlQualifiedName(String value)
System::SharedPtr< IXmlSerializable > ReadSerializable(System::SharedPtr< IXmlSerializable > serializable)
void UnreferencedObject(String id, System::SharedPtr< Object > o)
Exception CreateMissingIXmlSerializableType(String name, String ns, String clrType)
Exception CreateInvalidCastException(const TypeInfo &type, System::SharedPtr< Object > value, String id)
System::ArrayPtr< T > ShrinkArray(System::ArrayPtr< T > a, int length, TypeInfo elementType, bool isNullable)
Definition: xml_serialization_reader.h:88
void UnknownElement(System::SharedPtr< Object > o, System::SharedPtr< XmlElement > elem)
void UnknownNode(System::SharedPtr< Object > o)
System::ArrayPtr< uint8_t > ToByteArrayHex(bool isNull)
System::SharedPtr< Object > ReadTypedNull(System::SharedPtr< XmlQualifiedName > type)
System::SharedPtr< XmlReader > get_Reader()
Exception CreateInvalidCastException(const TypeInfo &type, System::SharedPtr< Object > value)
void UnknownNode(System::SharedPtr< Object > o, String qnames)
System::SharedPtr< XmlQualifiedName > ReadNullableQualifiedName()
Exception CreateBadDerivationException(String xsdDerived, String nsDerived, String xsdBase, String nsBase, String clrDerived, String clrBase)
System::SharedPtr< Object > ReadReferencedElement(String name, String ns)
System::SharedPtr< XmlDocument > get_Document()
String ReadString(String value, bool trim)
void Referenced(System::SharedPtr< Object > o)
void AddTarget(String id, System::SharedPtr< Object > o)
int64_t ToEnum(String value, System::SharedPtr< System::Collections::Generic::Dictionary< System::String, int64_t > > h, String typeName)
void UnknownElement(System::SharedPtr< Object > o, System::SharedPtr< XmlElement > elem, String qnames)
Exception CreateAbstractTypeException(String name, String ns)
System::ArrayPtr< uint8_t > ToByteArrayBase64(bool isNull)
System::SharedPtr< Object > ReadReferencedElement()
static System::ArrayPtr< uint8_t > ToByteArrayBase64(String value)
Exception CreateCtorHasSecurityException(String typeName)
System::SharedPtr< XmlDocument > ReadXmlDocument(bool wrapped)
static System::SharedPtr< Reflection::Assembly > ResolveDynamicAssembly(String assemblyFullName)
void Initialize(System::SharedPtr< XmlReader > reader, System::SharedPtr< XmlSerializer > eventSource)
Initializes XmlSerializationReader class.
System::ArrayPtr< T > EnsureArrayIndex(System::ArrayPtr< T > a, int index, System::TypeInfo elementType)
Definition: xml_serialization_reader.h:61
System::SharedPtr< Object > ReadTypedPrimitive(System::SharedPtr< XmlQualifiedName > type)
System::SharedPtr< Object > ReadReferencingElement(String name, String ns, String &fixupReference)
Exception CreateUnknownConstantException(String value, const TypeInfo &enumType)
void ParseWsdlArrayType(System::SharedPtr< XmlAttribute > attr)
System::SharedPtr< Object > ReadReferencingElement(String &fixupReference)
void UnknownAttribute(System::SharedPtr< Object > o, System::SharedPtr< XmlAttribute > attr)
void FixupArrayRefs(System::SharedPtr< Object > fixup)
System::SharedPtr< Object > GetTarget(String id)
System::SharedPtr< XmlQualifiedName > ReadElementQualifiedName()
int32_t GetArrayLength(String name, String ns)
void UnknownAttribute(System::SharedPtr< Object > o, System::SharedPtr< XmlAttribute > attr, String qnames)
System::SharedPtr< Object > ReadReferencingElement(String name, String ns, bool elementCanBeType, String &fixupReference)
System::SharedPtr< XmlNode > ReadXmlNode(bool wrapped)
System::SharedPtr< IXmlSerializable > ReadSerializable(System::SharedPtr< IXmlSerializable > serializable, bool wrappedAny)
Exception CreateInaccessibleConstructorException(String typeName)
Exception CreateUnknownTypeException(System::SharedPtr< XmlQualifiedName > type)
System::SharedPtr< XmlQualifiedName > GetXsiType()
void CheckReaderCount(int32_t &whileIterations, int32_t &readerCount)
@ Xml
Serialize according to the XML 1.0 rules.
Definition: db_command.h:9