Inheritance: IPhpConvertible, IPhpArray
Exemplo n.º 1
0
        public TextElement(PhpString str, Encoding encoding)
        {
            Debug.Assert(str != null);
            _data = str.ContainsBinaryData
                ? (object)str.ToBytes(encoding)
                : str.ToString(encoding);

            Debug.Assert(IsText ^ IsBinary);
        }
Exemplo n.º 2
0
        public void Append(PhpString value)
        {
            if (value != null && !value.IsEmpty)
            {
                Debug.Assert(value._chunks != null);

                if (value.IsArrayOfChunks)
                {
                    AddChunk(value);
                }
                else
                {
                    AddChunk(value._chunks);    // if containing only one chunk, add it directly
                }

                _flags |= (value._flags & Flags.ContainsBinary);    // maintain the binary data flag
            }
        }
Exemplo n.º 3
0
            public void Append(PhpString value)
            {
                if (value != null && !value.IsEmpty)
                {
                    Debug.Assert(value._blob._chunks != null);

                    if (value._blob.IsArrayOfChunks)
                    {
                        AddChunk(value.DeepCopy());
                    }
                    else
                    {
                        // if containing only one chunk, add it directly
                        var chunk = value._blob._chunks;
                        InplaceDeepCopy(ref chunk);
                        AddChunk(chunk);
                    }

                    _flags |= (value._blob._flags & (Flags.ContainsBinary | Flags.ContainsMutables));    // maintain the binary data flag
                }
            }
Exemplo n.º 4
0
        /// <summary>
        /// Gets value indicating the variable contains a single-byte string value.
        /// </summary>
        public static bool IsBinaryString(this PhpValue value, out PhpString @string)
        {
            switch (value.TypeCode)
            {
            case PhpTypeCode.MutableString:
                if (value.MutableStringBlob.ContainsBinaryData)
                {
                    @string = value.MutableString;
                    return(true);
                }
                else
                {
                    goto default;
                }

            case PhpTypeCode.Alias:
                return(value.Alias.Value.IsBinaryString(out @string));

            default:
                @string = default;
                return(false);
            }
        }
Exemplo n.º 5
0
 public static stdClass ToObject(PhpString value) => new stdClass(PhpValue.Create(value.DeepCopy()));
Exemplo n.º 6
0
 /// <summary>
 /// Converts string to boolean according to PHP.
 /// </summary>
 public static bool ToBoolean(PhpString value) => value.ToBoolean();
Exemplo n.º 7
0
 /// <summary>
 /// Converts mutable string to byte[].
 /// </summary>
 public static byte[] ToBytes(PhpString value, Context ctx) => value.ToBytes(ctx);
Exemplo n.º 8
0
 /// <summary>
 /// Converts mutable string to string.
 /// </summary>
 public static string ToString(PhpString value, Context ctx) => value.ToString(ctx);
Exemplo n.º 9
0
            public override IPhpArray EnsureArray(ref PhpValue me)
            {
                var arr = new PhpString(me.String);

                // me is changed if value is empty
                if (string.IsNullOrEmpty(me.String))
                    me = PhpValue.Create(arr);

                return arr;
            }
Exemplo n.º 10
0
 public static PhpValue Create(PhpString value) => new PhpValue(TypeTable.WritableStringTable, value);
Exemplo n.º 11
0
 /// <summary>
 /// Gets instance of blob that is not shared.
 /// </summary>
 public static Blob AsWritable(PhpString str) => str.EnsureWritable();
Exemplo n.º 12
0
 public PhpString(PhpString from)
 {
     _blob = from._blob.AddRef();
 }
Exemplo n.º 13
0
        public void Append(PhpString value)
        {
            if (value != null && !value.IsEmpty)
            {
                Debug.Assert(value._chunks != null);

                if (value.IsArrayOfChunks)
                {
                    AddChunk(value);
                }
                else
                {
                    AddChunk(value._chunks);    // if containing only one chunk, add it directly
                }

                _flags |= (value._flags & Flags.ContainsBinary);    // maintain the binary data flag
            }
        }
Exemplo n.º 14
0
 public PhpString(PhpString from)
     : this(from._blob?.AddRef())
 {
 }
Exemplo n.º 15
0
 public static bool IsMutableString(this PhpValue value, out PhpString @string) => value.IsMutableStringImpl(out @string);
Exemplo n.º 16
0
 public void Append(PhpString value) => Add(value);
Exemplo n.º 17
0
 /// <summary>
 /// Wraps the string into <see cref="PhpValue"/>.
 /// </summary>
 public PhpValue AsPhpValue(PhpString str) => str.IsEmpty ? PhpValue.Create(string.Empty) : PhpValue.Create(str._blob);
Exemplo n.º 18
0
 /// <summary>
 /// Gets read-only array access to the string.
 /// For write access, use <see cref="EnsureWritable()"/>.
 /// </summary>
 public static Blob AsArray(PhpString str) => str._blob ?? new Blob();
Exemplo n.º 19
0
 /// <summary>
 /// Performs conversion of a value to a number.
 /// </summary>
 public static PhpNumber ToNumber(PhpString value) => value.ToNumber();
Exemplo n.º 20
0
 public void Echo(PhpString value) => value.Output(this);
Exemplo n.º 21
0
 /// <summary>
 /// Operator that checks the string is default/uninitialized not containing any value.
 /// </summary>
 public static bool IsNull(PhpString value) => value.IsDefault;
Exemplo n.º 22
0
 public override void Accept(PhpString obj) => _output.Append(obj);
Exemplo n.º 23
0
 public override void Accept(PhpString obj)
 {
     _output.Append("'");
     _output.Append(obj);
     _output.Append("'");
 }
Exemplo n.º 24
0
 public void Append(PhpString value) => EnsureWritable().Append(value);
Exemplo n.º 25
0
            public PhpString Serialize(PhpValue value)
            {
                _output = new PhpString();
                _indent = 0;

                //
                Accept(value);
                _output.Append(_nl);

                return _output;
            }
Exemplo n.º 26
0
 public static PhpValue Create(PhpString value) => PhpString.AsPhpValue(value);
Exemplo n.º 27
0
 public override void Accept(PhpString obj)
 {
     _output.Append(PhpVariable.TypeNameString);
     _output.Append($"({obj.Length}) ");
     _output.Append("\"");
     _output.Append(obj);
     _output.Append("\"");
 }
Exemplo n.º 28
0
 public virtual void Accept(PhpString obj)
 {
 }
Exemplo n.º 29
0
 public void Echo(PhpString value) => value.Output(this);