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