• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## @file
2# This file is used to create/update/query/erase table for Identifiers
3#
4# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
5# This program and the accompanying materials
6# are licensed and made available under the terms and conditions of the BSD License
7# which accompanies this distribution.  The full text of the license may be found at
8# http://opensource.org/licenses/bsd-license.php
9#
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12#
13
14##
15# Import Modules
16#
17import Common.EdkLogger as EdkLogger
18from Common.String import ConvertToSqlString
19from Table import Table
20
21## TableIdentifier
22#
23# This class defined a table used for Identifier
24#
25# @param object:       Inherited from object class
26#
27#
28class TableIdentifier(Table):
29    def __init__(self, Cursor):
30        Table.__init__(self, Cursor)
31        self.Table = 'Identifier'
32
33    ## Create table
34    #
35    # Create table Identifier
36    #
37    # @param ID:                 ID of a Identifier
38    # @param Modifier:           Modifier of a Identifier
39    # @param Type:               Type of a Identifier
40    # @param Name:               Name of a Identifier
41    # @param Value:              Value of a Identifier
42    # @param Model:              Model of a Identifier
43    # @param BelongsToFile:      The Identifier belongs to which file
44    # @param BelongsToFunction:  The Identifier belongs to which function
45    # @param StartLine:          StartLine of a Identifier
46    # @param StartColumn:        StartColumn of a Identifier
47    # @param EndLine:            EndLine of a Identifier
48    # @param EndColumn:          EndColumn of a Identifier
49    #
50    def Create(self):
51        SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,
52                                                      Modifier VARCHAR,
53                                                      Type VARCHAR,
54                                                      Name VARCHAR NOT NULL,
55                                                      Value VARCHAR NOT NULL,
56                                                      Model INTEGER NOT NULL,
57                                                      BelongsToFile SINGLE NOT NULL,
58                                                      BelongsToFunction SINGLE DEFAULT -1,
59                                                      StartLine INTEGER NOT NULL,
60                                                      StartColumn INTEGER NOT NULL,
61                                                      EndLine INTEGER NOT NULL,
62                                                      EndColumn INTEGER NOT NULL
63                                                     )""" % self.Table
64        Table.Create(self, SqlCommand)
65
66    ## Insert table
67    #
68    # Insert a record into table Identifier
69    #
70    # @param ID:                 ID of a Identifier
71    # @param Modifier:           Modifier of a Identifier
72    # @param Type:               Type of a Identifier
73    # @param Name:               Name of a Identifier
74    # @param Value:              Value of a Identifier
75    # @param Model:              Model of a Identifier
76    # @param BelongsToFile:      The Identifier belongs to which file
77    # @param BelongsToFunction:  The Identifier belongs to which function
78    # @param StartLine:          StartLine of a Identifier
79    # @param StartColumn:        StartColumn of a Identifier
80    # @param EndLine:            EndLine of a Identifier
81    # @param EndColumn:          EndColumn of a Identifier
82    #
83    def Insert(self, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn):
84        self.ID = self.ID + 1
85        (Modifier, Type, Name, Value) = ConvertToSqlString((Modifier, Type, Name, Value))
86        SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
87                                           % (self.Table, self.ID, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn)
88        Table.Insert(self, SqlCommand)
89
90        return self.ID