BTDB.StreamLayer.AbstractBufferedReader.ReadString C# (CSharp) Méthode

ReadString() public méthode

public ReadString ( ) : string
Résultat string
        public string ReadString()
        {
            var len = ReadVUInt64();
            if (len == 0) return null;
            len--;
            if (len > int.MaxValue) throw new InvalidDataException($"Reading String length overflowed with {len}");
            var l = (int)len;
            if (l == 0) return "";
            ReserveCharBuf(l);
            var res = CharBuf;
            var i = 0;
            while (i < l)
            {
                if (Pos != End)
                {
                    var b = Buf[Pos];
                    if (b < 0x80)
                    {
                        res[i] = (char)b;
                        i++;
                        Pos++;
                        continue;
                    }
                }
                var c = ReadVUInt64();
                if (c > 0xffff)
                {
                    if (c > 0x10ffff) throw new InvalidDataException($"Reading String unicode value overflowed with {c}");
                    c -= 0x10000;
                    res[i] = (char)((c >> 10) + 0xD800);
                    i++;
                    res[i] = (char)((c & 0x3FF) + 0xDC00);
                    i++;
                }
                else
                {
                    res[i] = (char)c;
                    i++;
                }
            }
            return new string(res, 0, l);
        }

Usage Example

Exemple #1
0
 internal static TableFieldInfo Load(AbstractBufferedReader reader, IFieldHandlerFactory fieldHandlerFactory, string tableName)
 {
     var name = reader.ReadString();
     var handlerName = reader.ReadString();
     var configuration = reader.ReadByteArray();
     var fieldHandler = fieldHandlerFactory.CreateFromName(handlerName, configuration, FieldHandlerOptions.None);
     if (fieldHandler == null) throw new BTDBException(string.Format("FieldHandlerFactory did not created handler {0} in {1}.{2}", handlerName, tableName, name));
     return new TableFieldInfo(name, fieldHandler);
 }
All Usage Examples Of BTDB.StreamLayer.AbstractBufferedReader::ReadString