3#include <system/value_tuple.h>
4#include <system/text/encoding.h>
5#include <system/span.h>
6#include <system/object_ext.h>
7#include <system/memory_extensions.h>
8#include <system/math.h>
9#include <system/icomparable.h>
10#include <system/func.h>
11#include <system/details/stack_array.h>
12#include <system/details/patterns.h>
13#include <system/details/object_builder.h>
14#include <system/constraints.h>
15#include <system/collections/queue.h>
16#include <system/collections/list.h>
17#include <system/collections/ienumerator.h>
18#include <system/collections/icollection.h>
19#include <system/collections/dictionary.h>
20#include <system/array.h>
30template <
typename>
class IEnumerable;
31template <
typename>
class IEqualityComparer;
32template <
typename,
typename>
class KeyValuePair;
39template <
typename>
class Nullable;
46class JavaScriptEncoder;
58namespace RegularExpressions
77 class DateTimeParseData :
public System::Object,
public System::Details::BoxableObjectBase
82 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
90 bool IsCalendarDateOnly;
96 int32_t OffsetMinutes;
98 bool get_OffsetNegative();
112 static ASPOSECPP_SHARED_API
bool IsInRangeInclusive(uint32_t value, uint32_t lowerBound, uint32_t upperBound);
113 static ASPOSECPP_SHARED_API
bool IsInRangeInclusive(int32_t value, int32_t lowerBound, int32_t upperBound);
114 static ASPOSECPP_SHARED_API
bool IsInRangeInclusive(int64_t value, int64_t lowerBound, int64_t upperBound);
116 static ASPOSECPP_SHARED_API
bool IsDigit(uint8_t value);
120 template<
typename TValue>
124 return dictionary->TryGetValue(key, result);
127 template<
typename TKey,
typename TValue>
131 return System::MakeObject<Collections::Generic::Dictionary<TKey, TValue>>(collection, comparer);
138 template<
typename T,
typename TKey>
141 assert_is_cs_struct(TKey);
143 assert_is_base_of(BaseT_IComparable, TKey);
145 auto arrayCopy = items->ToArray();
146 auto& data = arrayCopy->data();
147 std::stable_sort(data.begin(), data.end(),
148 [&](
const T& left,
const T& right)
150 return keySelector(left) < keySelector(right);
154 items->AddRange(arrayCopy);
160 if (System::IsNull(comparer))
168 auto nodes = System::BuildObject<Collections::Generic::List<T>>().Add(entryNode).Get();
170 auto nodeIndex = [&]{
auto tmp_0 = System::MakeObject<Collections::Generic::Dictionary<T, int32_t>>(comparer);
171 tmp_0->idx_set(entryNode, 0);
return tmp_0; }();
173 auto adjacency = System::MakeObject<Collections::Generic::List<System::SharedPtr<Array<bool>>>>();
175 auto childlessQueue = System::MakeObject<Collections::Generic::Queue<int32_t>>();
178 for (int32_t i = 0; i < nodes->get_Count(); i++)
180 T next = nodes->idx_get(i);
182 int32_t count = children->get_Count();
186 adjacency->Add(
nullptr);
188 childlessQueue->Enqueue(i);
192 auto adjacencyRow = System::MakeArray<bool>(
System::Math::Max(nodes->get_Count(), count),
false);
194 auto childNode_enumerator = (children)->GetEnumerator();
195 while (childNode_enumerator->MoveNext())
197 auto&& childNode = childNode_enumerator->get_Current();
200 if (!nodeIndex->TryGetValue(childNode,
index))
205 index = nodes->get_Count();
206 nodeIndex->Add(childNode,
index);
207 nodes->Add(childNode);
211 if (
index >= adjacencyRow->get_Length())
217 adjacencyRow[
index] =
true;
222 adjacency->Add(adjacencyRow);
226 auto sortedNodes = System::MakeArray<T>(nodes->get_Count());
227 int32_t idx = sortedNodes->get_Length();
231 int32_t nextIndex = childlessQueue->Dequeue();
232 sortedNodes[--idx] = nodes->idx_get(nextIndex);
235 for (int32_t i = 0; i < adjacency->get_Count(); i++)
238 if (childMap !=
nullptr && nextIndex < childMap->get_Length() && (*childMap)[nextIndex])
240 (*childMap)[nextIndex] =
false;
245 childlessQueue->Enqueue(i);
249 }
while (childlessQueue->get_Count() > 0);
263 static const String IntegerRegexPattern;
264 static const int32_t IntegerRegexTimeoutMs = 200;
271 static bool TryParseDateTimeOffset(
ReadOnlySpan<uint8_t> source, JsonHelpers::DateTimeParseData& parseData);
273 static bool TryCreateDateTimeOffset(
DateTime dateTime, JsonHelpers::DateTimeParseData& parseData,
DateTimeOffset& value);
274 static bool TryCreateDateTimeOffset(JsonHelpers::DateTimeParseData& parseData,
DateTimeOffset& value);
275 static bool TryCreateDateTimeOffsetInterpretingDataAsLocalTime(JsonHelpers::DateTimeParseData parseData,
DateTimeOffset& value);
276 static bool TryCreateDateTime(JsonHelpers::DateTimeParseData parseData,
DateTimeKind kind,
DateTime& value);
static void Resize(ArrayPtr< Type > &arr, int new_size)
Changes the size of the specified array to the specified value or crates new array with specified siz...
Definition: array.h:1518
Forward declaration of Dictionary class.
Definition: dictionary.h:96
Interface of collection of elements. Objects of this class should only be allocated using System::Mak...
Definition: icollection.h:20
Interface of object providing enumerator on contained elements.
Definition: ienumerable.h:26
Interface providing means to compare two objects for equality. Objects of this class should only be a...
Definition: iequality_comparer.h:18
Pair of key and value. This type should be allocated on stack and passed to functions by value or by ...
Definition: keyvalue_pair.h:20
List forward declaration.
Definition: list.h:129
Represents a specific date and time value on the time continuum. This type should be allocated on sta...
Definition: date_time.h:50
Contains the date and time of day relative to Coordinated Universal Time. Objects of this class shoul...
Definition: date_time_offset.h:16
Function delegate. This type should be allocated on stack and passed to functions by value or by refe...
Definition: func.h:82
Defines a method that compares two objects. Objects of this class should only be allocated using Syst...
Definition: icomparable.h:17
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:51
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:126
static EncodingPtr get_UTF8()
Gets the standard UTF-8 encoding object.
virtual String GetString(uint8_t *bytes, int byte_count)
Decodes a buffer of bytes into a string.
Definition: json_helpers.h:72
static bool TryAdvanceWithOptionalReadAhead(Utf8JsonReader &reader, bool requiresReadAhead)
static System::SharedPtr< Collections::Generic::Dictionary< TKey, TValue > > CreateDictionaryFromCollection(System::SharedPtr< Collections::Generic::IEnumerable< Collections::Generic::KeyValuePair< TKey, TValue > > > collection, System::SharedPtr< Collections::Generic::IEqualityComparer< TKey > > comparer)
Definition: json_helpers.h:128
static bool IsValidDateTimeOffsetParseLength(int32_t length)
static bool IsDigit(uint8_t value)
static bool TrySkipPartial(Utf8JsonReader &reader)
static void ReadWithVerify(Utf8JsonReader &reader)
static void ValidateInt32MaxArrayLength(uint32_t length)
static System::SharedPtr< Array< T > > TraverseGraphWithTopologicalSort(T entryNode, Func< T, System::SharedPtr< Collections::Generic::ICollection< T > > > getChildren, System::SharedPtr< Collections::Generic::IEqualityComparer< T > > comparer=nullptr)
Definition: json_helpers.h:158
static bool TryParseAsISO(ReadOnlySpan< uint8_t > source, DateTimeOffset &value)
static bool IsInRangeInclusive(uint32_t value, uint32_t lowerBound, uint32_t upperBound)
static bool IsInRangeInclusive(JsonTokenType value, JsonTokenType lowerBound, JsonTokenType upperBound)
static bool TryLookupUtf8Key(System::SharedPtr< Collections::Generic::Dictionary< String, TValue > > dictionary, ReadOnlySpan< uint8_t > utf8Key, TValue &result)
Definition: json_helpers.h:121
static System::SharedPtr< Array< uint8_t > > GetEscapedPropertyNameSection(ReadOnlySpan< uint8_t > utf8Value, System::SharedPtr< Encodings::Web::JavaScriptEncoder > encoder)
static bool TryParseAsISO(ReadOnlySpan< uint8_t > source, DateTime &value)
static bool IsInRangeInclusive(int64_t value, int64_t lowerBound, int64_t upperBound)
static System::SharedPtr< RegularExpressions::Regex > get_IntegerRegex()
static ReadOnlySpan< uint8_t > GetUnescapedSpan(Utf8JsonReader &reader)
static bool AreEqualJsonNumbers(ReadOnlySpan< uint8_t > left, ReadOnlySpan< uint8_t > right)
static void SkipWithVerify(Utf8JsonReader &reader)
static void StableSortByKey(System::SharedPtr< Collections::Generic::List< T > > items, Func< T, TKey > keySelector)
Definition: json_helpers.h:139
static bool IsValidUnescapedDateTimeOffsetParseLength(int32_t length)
static bool IsInRangeInclusive(int32_t value, int32_t lowerBound, int32_t upperBound)
static bool RequiresSpecialNumberHandlingOnWrite(Nullable< Serialization::JsonNumberHandling > handling)
static System::SharedPtr< Array< uint8_t > > EscapeValue(ReadOnlySpan< uint8_t > utf8Value, int32_t firstEscapeIndexVal, System::SharedPtr< Encodings::Web::JavaScriptEncoder > encoder)
Definition: utf8_json_reader.h:78
@ Text
Defines color adjustment information for text.
Span< T > AsSpan(const ArrayPtr< T > &array, int32_t start=0, int32_t length=-1)
Creates a span from an array.
Definition: memory_extensions.h:2051
int32_t IndexOf(const ReadOnlySpan< T > &span, const ReadOnlySpan< T > &value)
Finds the index of a ReadOnlySpan<T> value in another ReadOnlySpan<T>
Definition: memory_extensions.h:2475
JsonNumberHandling
Definition: json_number_handling.h:16
JsonTokenType
Definition: json_token_type.h:12
Definition: db_command.h:9
DateTimeKind
Enumeration values of which represent the kinds of date and time.
Definition: date_time_kind.h:10
decltype(Ref(std::declval< T & >())) Ref(const std::reference_wrapper< T > &wrapper)
Wrapper to make sure Ref(std::ref(DynamicWeakPtr)) works.
Definition: dynamic_weak_ptr.h:207
static auto Max(T0 val1, T1 val2) -> decltype(val1+val2)
Returns the greatest value out of two numeric ones specified.
Definition: math.h:327