Beispiel #1
0
    public int                                             GetMultiSize(string Key)
    {
        cLineValue pLineValue = null; cMultiValue pMultiValue = null;

        return((
                   ((pLineValue = GetLineValue(Key)) != null) &&
                   ((pMultiValue = pLineValue.GetMultiValue()) != null)) ?
               (pMultiValue.Size() + 1) : 0);
    }
Beispiel #2
0
    public void                                    SetValue(string Key, cValue Value)
    {
        cLineValue pLineValue = GetLineValue(Key);

        // if not exists create one
        if (pLineValue == null)
        {
            pLineValue = new cLineValue(Key, ( byte )LineValueType.SINGLE);
        }
        pLineValue.Clear();
        pLineValue.Set(Value);
    }
Beispiel #3
0
    public void                                    SetMultiValue(string Key, List <cValue> vValues)
    {
        cLineValue pLineValue = GetLineValue(Key);

        // if not exists create one
        if (pLineValue == null)
        {
            pLineValue = new cLineValue(Key, ( byte )LineValueType.MULTI);
        }
        pLineValue.Clear();
        pLineValue.Set(new cMultiValue(vValues));
    }
Beispiel #4
0
    public string                                  GetString(string Key, string Default = "")
    {
        cLineValue pLineValue = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            if (pLineValue.Type() == ( byte )LineValueType.SINGLE)
            {
                return(pLineValue.GetValue().ToString());
            }
        }
        return(Default);
    }
Beispiel #5
0
    public float                                   GetFloat(string Key, float Default = 0.0f)
    {
        cLineValue pLineValue = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            if (pLineValue.Type() == ( byte )LineValueType.SINGLE)
            {
                return(pLineValue.GetValue().ToFloat());
            }
        }
        return(Default);
    }
Beispiel #6
0
    public int                                             GetInt(string Key, int Default = 0)
    {
        cLineValue pLineValue = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            if (pLineValue.Type() == ( byte )LineValueType.SINGLE)
            {
                return(pLineValue.GetValue().ToInteger());
            }
        }
        return(Default);
    }
Beispiel #7
0
    public bool                                    GetBool(string Key, bool Default = false)
    {
        cLineValue pLineValue = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            if (pLineValue.Type() == ( byte )LineValueType.SINGLE)
            {
                return(pLineValue.GetValue().ToBool());
            }
        }
        return(Default);
    }
Beispiel #8
0
    // INSERT A KEY VALUE PAIR INSIDE THE ACTUAL PARSING SECTION
    private bool Section_Add(KeyValue Pair, string sFilePath, int iLine)
    {
        cLineValue pLineValue = new cLineValue(Pair.Key, Pair.Value);

        if (!pLineValue.IsOK())
        {
            Debug.LogError(" Reader::Section_Add:LineValue invalid for key |" + Pair.Key + "| in Section |" + pSection.Name() + "| in file |" + sFilePath + "|");
            return(false);
        }

        pSection.Add(pLineValue);

        return(true);
    }
Beispiel #9
0
    public bool                                    bGetBool(string Key, out bool Out, bool Default = false)
    {
        cLineValue pLineValue = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            if (pLineValue.Type() == ( byte )LineValueType.SINGLE)
            {
                Out = pLineValue.GetValue().ToBool();
                return(true);
            }
        }

        Out = Default;
        return(false);
    }
Beispiel #10
0
    public bool                                    bGetInt(string Key, out int Out, int Default = 0)
    {
        cLineValue pLineValue = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            if (pLineValue.Type() == ( byte )LineValueType.SINGLE)
            {
                Out = pLineValue.GetValue().ToInteger();
                return(true);
            }
        }

        Out = Default;
        return(false);
    }
Beispiel #11
0
    public bool                                    bGetString(string Key, out string Out, string Default = "")
    {
        cLineValue pLineValue = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            if (pLineValue.Type() == ( byte )LineValueType.SINGLE)
            {
                Out = pLineValue.GetValue().ToString();
                return(true);
            }
        }

        Out = Default;
        return(false);
    }
Beispiel #12
0
    public bool                                    bGetFloat(string Key, out float Out, float Default = 0.0f)
    {
        cLineValue pLineValue = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            if (pLineValue.Type() == ( byte )LineValueType.SINGLE)
            {
                Out = pLineValue.GetValue().ToFloat();
                return(true);
            }
        }

        Out = Default;
        return(false);
    }
Beispiel #13
0
    public void                    SetVec4(string Key, Vector4 Vec)
    {
        cLineValue pLineValue = GetLineValue(Key);

        // if not exists create one
        if (pLineValue == null)
        {
            pLineValue = new cLineValue(Key, ( byte )LineValueType.MULTI);
        }
        pLineValue.Clear();

        List <cValue> vValues = new List <cValue> {
            new cValue(Vec.x), new cValue(Vec.y), new cValue(Vec.z), new cValue(Vec.w)
        };

        pLineValue.Set(new cMultiValue(vValues));
    }
Beispiel #14
0
    public cValue                                  GetMultiValue(string Key, int Index, int Type)
    {
        cLineValue pLineValue = null; cMultiValue pMultiValue = null; cValue pValue = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            if ((pMultiValue = pLineValue.GetMultiValue()) != null)
            {
                if ((pValue = pMultiValue.At(Index - 1)) != null)
                {
                    return(pValue);
                }
            }
        }

        return(null);
    }
Beispiel #15
0
    public bool                                    bGetMultiValue(string Key, out cValue Out, int Index, int Type)
    {
        cLineValue pLineValue = null; cMultiValue pMultiValue = null; cValue pValue = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            if ((pMultiValue = pLineValue.GetMultiValue()) != null)
            {
                if ((pValue = pMultiValue.At(Index - 1)) != null)
                {
                    Out = pValue;
                    return(true);
                }
            }
        }

        Out = null;
        return(false);
    }
Beispiel #16
0
    public cLineValue                              GetLineValue(string Key)
    {
        if (vSection.Count < 1)
        {
            return(null);
        }

        cLineValue pLineValue = null;

        foreach (cLineValue LineValue in vSection)
        {
            if (LineValue.IsKey(Key))
            {
                pLineValue = LineValue;
            }
        }

        return(pLineValue);
    }
Beispiel #17
0
    public bool                                    bGetVec2(string Key, out Vector2 Out, Vector2 Default)
    {
        cLineValue pLineValue = null; cMultiValue pMultiValue = null;
        cValue     pValue1 = null; cValue pValue2 = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            if ((pMultiValue = pLineValue.GetMultiValue()) != null)
            {
                if (((pValue1 = pMultiValue.At(0)) != null) &&
                    (pValue2 = pMultiValue.At(1)) != null)
                {
                    Out = new Vector2(pValue1.ToFloat(), pValue2.ToFloat());
                    return(true);
                }
            }
        }

        Out = Default;
        return(false);
    }
Beispiel #18
0
    // Return the type of a value assigned to a key, or -1
    public int                                             KeyType(string Key)
    {
        if (vSection.Count < 1)
        {
            return(-1);
        }

        cLineValue pLineValue = null; cValue Value = null;

        if ((pLineValue = GetLineValue(Key)) != null)
        {
            int iType = pLineValue.Type();
            switch (iType)
            {
            case ( byte )LineValueType.SINGLE: {
                if ((Value = pLineValue.GetValue()) != null)
                {
                    return(Value.Type());
                }
                Debug.LogError("cSection::KeyType:WARNING! In section " + sName + " a key has no value but designed as SINGLE !!!");
                break;
            }

            case ( byte )LineValueType.MULTI: {
                if ((pLineValue.GetMultiValue() != null))
                {
                    return(iType);
                }
                Debug.LogError("cSection::KeyType:WARNING! In section " + sName + " a key has no value but designed as MULTI !!!");
                break;
            }
            }
        }

        return(-1);
    }
Beispiel #19
0
 public void                                    Add(cLineValue LineValue)
 {
     vSection.Add(LineValue);
 }
Beispiel #20
0
    public string                                  GetRawValue(string Key, string Default = "")
    {
        cLineValue pLineValue = null;

        return(((pLineValue = GetLineValue(Key)) != null) ? pLineValue.RawValue() : Default);
    }