]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TablePcd.py
d58a3ef49e02a6da3ccf2d605e87521497e853f1
[mirror_edk2.git] / BaseTools / Source / Python / Table / TablePcd.py
1 ## @file
2 # This file is used to create/update/query/erase table for pcds
3 #
4 # Copyright (c) 2008 - 2018, 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 #
17 from __future__ import absolute_import
18 import Common.EdkLogger as EdkLogger
19 from .Table import Table
20 from Common.StringUtils import ConvertToSqlString
21
22 ## TablePcd
23 #
24 # This class defined a table used for pcds
25 #
26 # @param object: Inherited from object class
27 #
28 #
29 class TablePcd(Table):
30 def __init__(self, Cursor):
31 Table.__init__(self, Cursor)
32 self.Table = 'Pcd'
33
34 ## Create table
35 #
36 # Create table Pcd
37 #
38 # @param ID: ID of a Pcd
39 # @param CName: CName of a Pcd
40 # @param TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd
41 # @param Token: Token of a Pcd
42 # @param DatumType: DatumType of a Pcd
43 # @param Model: Model of a Pcd
44 # @param BelongsToFile: The Pcd belongs to which file
45 # @param BelongsToFunction: The Pcd belongs to which function
46 # @param StartLine: StartLine of a Pcd
47 # @param StartColumn: StartColumn of a Pcd
48 # @param EndLine: EndLine of a Pcd
49 # @param EndColumn: EndColumn of a Pcd
50 #
51 def Create(self):
52 SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
53 CName VARCHAR NOT NULL,
54 TokenSpaceGuidCName VARCHAR NOT NULL,
55 Token INTEGER,
56 DatumType VARCHAR,
57 Model INTEGER NOT NULL,
58 BelongsToFile SINGLE NOT NULL,
59 BelongsToFunction SINGLE DEFAULT -1,
60 StartLine INTEGER NOT NULL,
61 StartColumn INTEGER NOT NULL,
62 EndLine INTEGER NOT NULL,
63 EndColumn INTEGER NOT NULL
64 )""" % self.Table
65 Table.Create(self, SqlCommand)
66
67 ## Insert table
68 #
69 # Insert a record into table Pcd
70 #
71 # @param ID: ID of a Pcd
72 # @param CName: CName of a Pcd
73 # @param TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd
74 # @param Token: Token of a Pcd
75 # @param DatumType: DatumType of a Pcd
76 # @param Model: Model of a Pcd
77 # @param BelongsToFile: The Pcd belongs to which file
78 # @param BelongsToFunction: The Pcd belongs to which function
79 # @param StartLine: StartLine of a Pcd
80 # @param StartColumn: StartColumn of a Pcd
81 # @param EndLine: EndLine of a Pcd
82 # @param EndColumn: EndColumn of a Pcd
83 #
84 def Insert(self, CName, TokenSpaceGuidCName, Token, DatumType, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn):
85 self.ID = self.ID + 1
86 (CName, TokenSpaceGuidCName, DatumType) = ConvertToSqlString((CName, TokenSpaceGuidCName, DatumType))
87 SqlCommand = """insert into %s values(%s, '%s', '%s', %s, '%s', %s, %s, %s, %s, %s, %s, %s)""" \
88 % (self.Table, self.ID, CName, TokenSpaceGuidCName, Token, DatumType, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn)
89 Table.Insert(self, SqlCommand)
90
91 return self.ID