public ImmutableKeyValue Parse(ReadOnlySpan <byte> data, KeyValueParserConfig config) { _conditions = config?.Conditions ?? KeyValueParserConfig.GetDefaultConditions(); _values = data; _valuesIndex = 0; _db = new KVDatabase.Builder(config?.Pool ?? MemoryPool <byte> .Default, data.Length / 8); ref DbRow topRow = ref _db.AppendRow();
/// <summary> /// Loads a UTF8 file at the specified path and parses it as a text stream /// </summary> /// <param name="file"></param> /// <param name="config"></param> /// <returns></returns> public static ImmutableKeyValue FromFile(string file, KeyValueParserConfig config = null) { var bytes = File.ReadAllBytes(file); if (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) { return(Parse(new Span <byte>(bytes).Slice(3), config)); } else { return(Parse(bytes, config)); } }
/// <summary> /// Parses the specified <see cref="ReadOnlySpan{T}"/> as a text stream /// </summary> /// <param name="utf8KeyValue"></param> /// <param name="config"></param> /// <returns></returns> public static ImmutableKeyValue Parse(ReadOnlySpan <byte> utf8KeyValue, KeyValueParserConfig config = null) { return(new KeyValueTextParser().Parse(utf8KeyValue, config)); }
/// <summary> /// Parses the specified byte array as a text stream /// </summary> /// <param name="data"></param> /// <param name="config"></param> /// <returns></returns> public static ImmutableKeyValue Parse(byte[] data, KeyValueParserConfig config = null) => Parse(new ReadOnlySpan <byte>(data), config);