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