Esempio n. 1
0
        public static int GetSize(HScriptParser.TypeContext context, bool IsLocal)
        {

            CellAffinity t = GetAffinity(context);
            
            // double, int, date are 8 bytes //
            if (t == CellAffinity.INT || t == CellAffinity.DOUBLE || t == CellAffinity.DATE_TIME)
                return 8;

            // Bools are 1 byte //
            if (t == CellAffinity.BOOL)
                return 1;

            // Variable length with a predefined size //
            if (context.LITERAL_INT() != null)
            {
                int size = int.Parse(context.LITERAL_INT().GetText());
                if (IsLocal)
                    return Math.Min(size, Schema.MAX_VARIABLE_SIZE);
                else
                    return Math.Min(size, Cell.MAX_STRING_LENGTH);
            }
            
            // Default the sizes //
            if (t == CellAffinity.STRING)
                return Schema.DEFAULT_STRING_SIZE;
            return Schema.DEFAULT_BLOB_SIZE;


        }