Example #1
0
    void WriteStringProperty(PdxBuffer buffer, Base data)
    {
        //Debug.Log("WriteStringProperty " + data.name + ": value count = " + data.value.Count);

        buffer.current.Write('!');
        //writeFixedString
        char[] chars = data.name.ToCharArray();
        buffer.current.Write((byte)chars.Length); buffer.current.Write(chars);

        buffer.current.Write('s');

        if (data.stringType > 0)
        {
            buffer.current.Write(data.stringType);
        }
        else
        {
            buffer.current.Write(1);
        }

        char[] charsVal = data.value[0].s.ToCharArray();
        int    l        = charsVal.Length + (data.nullByteString ? 1 : 0);

        buffer.current.Write(l);

        buffer.current.Write(charsVal);
        if (data.nullByteString)
        {
            buffer.current.Write((byte)0);
        }
    }
Example #2
0
    void WriteObject(PdxBuffer buffer, Base objectData)
    {
        //Debug.Log("WriteObject " + objectData.name + ": subnodes count = " + objectData.subNodes.Count + ", depth " + buffer.objectDepth);

        if (buffer.objectDepth > 20)
        {
            Debug.LogError("dead loop on " + objectData.name);
            return;
        }

        for (int i = 0; i < buffer.objectDepth; i++)
        {
            buffer.current.Write('[');
        }

        if (buffer.objectDepth > 0)
        {
            buffer.current.Write(objectData.name.TrimEnd('*').ToCharArray()); buffer.current.Write((byte)0);
        }
        buffer.objectDepth++;

        int l = objectData.subNodes.Count;

        List <Base> bases = new List <Base>(objectData.subNodes.Values);

        for (int i = 0; i < l; i++)
        {
            //objectData.subNodes.Values.
            WriteData(buffer, bases[i]);
        }

        buffer.objectDepth--;
    }
Example #3
0
    public void WriteToFile(Base data, string path)
    {
        using (BinaryWriter writer = new BinaryWriter(File.Open(path, FileMode.Create), System.Text.Encoding.ASCII))
        {
            PdxBuffer buffer = new PdxBuffer();
            buffer.current = writer;

            buffer.current.Write("@@b@".ToCharArray());
            WriteData(buffer, data);
        }
    }
Example #4
0
    void WriteFloatProperty(PdxBuffer buffer, Base data)
    {
        //Debug.Log("WriteFloatProperty " + data.name + ": value count = " + data.value.Count);

        buffer.current.Write('!');
        //writeFixedString
        char[] chars = data.name.ToCharArray();
        buffer.current.Write((byte)chars.Length); buffer.current.Write(chars);

        buffer.current.Write('f');

        int l = data.value.Count;

        buffer.current.Write(l);

        for (int i = 0; i < l; i++)
        {
            buffer.current.Write(data.value[i].f);
        }
    }
Example #5
0
    void WriteData(PdxBuffer buffer, Base data)
    {
        switch (data.type)
        {
        case "object":
            WriteObject(buffer, data);
            break;

        case "int":
            WriteIntProperty(buffer, data);
            break;

        case "float":
            WriteFloatProperty(buffer, data);
            break;

        case "string":
            WriteStringProperty(buffer, data);
            break;
        }
    }