Esempio n. 1
0
        /// <summary>Reads the data string as a FITS value-typed string.</summary>
        /// <returns>The value encoded in the DataString.</returns>
        string GetValueTypedValue()
        {
            if (DataString[0] != ' ')
            {
                throw new FITSFormatException("Record is not value type.");
            }
            int i, f;

            for (i = 0; i < DataString.Length && DataString[i] == ' '; i++)
            {
                ;
            }
            if (i == DataString.Length)
            {
                throw new FITSFormatException("Field is empty");
            }
            bool q = DataString[i] == '\'';

            f = i;
            if (q)
            {
                i++;
                if (DataString[i] == '\'')
                {
                    return(string.Empty);
                }
                i++;
                for (; i < DataString.Length; i++)
                {
                    if (DataString[i] == '\'' && DataString[i - 1] != '\'')
                    {
                        break;
                    }
                }
                return(DataString.Substring(f, i - f + 1).Replace("''", "'"));
            }
            else
            {
                for (; i < DataString.Length && DataString[i] != '/'; i++)
                {
                    ;
                }
                return(DataString.Substring(f, i - f).TrimEnd());
            }
        }