]> git.proxmox.com Git - mirror_edk2.git/blobdiff - 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
diff --git a/BaseTools/Source/Python/Table/TableIdentifier.py b/BaseTools/Source/Python/Table/TableIdentifier.py
new file mode 100644 (file)
index 0000000..3cf33f2
--- /dev/null
@@ -0,0 +1,90 @@
+## @file\r
+# This file is used to create/update/query/erase table for Identifiers\r
+#\r
+# Copyright (c) 2008, Intel Corporation\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+\r
+##\r
+# Import Modules\r
+#\r
+import Common.EdkLogger as EdkLogger\r
+from Common.String import ConvertToSqlString\r
+from Table import Table\r
+\r
+## TableIdentifier\r
+#\r
+# This class defined a table used for Identifier\r
+# \r
+# @param object:       Inherited from object class\r
+#\r
+#\r
+class TableIdentifier(Table):\r
+    def __init__(self, Cursor):\r
+        Table.__init__(self, Cursor)\r
+        self.Table = 'Identifier'\r
+    \r
+    ## Create table\r
+    #\r
+    # Create table Identifier\r
+    #\r
+    # @param ID:                 ID of a Identifier\r
+    # @param Modifier:           Modifier of a Identifier\r
+    # @param Type:               Type of a Identifier\r
+    # @param Name:               Name of a Identifier\r
+    # @param Value:              Value of a Identifier\r
+    # @param Model:              Model of a Identifier\r
+    # @param BelongsToFile:      The Identifier belongs to which file\r
+    # @param BelongsToFunction:  The Identifier belongs to which function\r
+    # @param StartLine:          StartLine of a Identifier\r
+    # @param StartColumn:        StartColumn of a Identifier\r
+    # @param EndLine:            EndLine of a Identifier\r
+    # @param EndColumn:          EndColumn of a Identifier\r
+    #\r
+    def Create(self):\r
+        SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,\r
+                                                      Modifier VARCHAR,\r
+                                                      Type VARCHAR,\r
+                                                      Name VARCHAR NOT NULL,\r
+                                                      Value VARCHAR NOT NULL,\r
+                                                      Model INTEGER NOT NULL,\r
+                                                      BelongsToFile SINGLE NOT NULL,\r
+                                                      BelongsToFunction SINGLE DEFAULT -1,\r
+                                                      StartLine INTEGER NOT NULL,\r
+                                                      StartColumn INTEGER NOT NULL,\r
+                                                      EndLine INTEGER NOT NULL,\r
+                                                      EndColumn INTEGER NOT NULL\r
+                                                     )""" % self.Table\r
+        Table.Create(self, SqlCommand)\r
+\r
+    ## Insert table\r
+    #\r
+    # Insert a record into table Identifier\r
+    #\r
+    # @param ID:                 ID of a Identifier\r
+    # @param Modifier:           Modifier of a Identifier\r
+    # @param Type:               Type of a Identifier\r
+    # @param Name:               Name of a Identifier\r
+    # @param Value:              Value of a Identifier\r
+    # @param Model:              Model of a Identifier\r
+    # @param BelongsToFile:      The Identifier belongs to which file\r
+    # @param BelongsToFunction:  The Identifier belongs to which function\r
+    # @param StartLine:          StartLine of a Identifier\r
+    # @param StartColumn:        StartColumn of a Identifier\r
+    # @param EndLine:            EndLine of a Identifier\r
+    # @param EndColumn:          EndColumn of a Identifier\r
+    #\r
+    def Insert(self, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn):\r
+        self.ID = self.ID + 1\r
+        (Modifier, Type, Name, Value) = ConvertToSqlString((Modifier, Type, Name, Value))\r
+        SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \\r
+                                           % (self.Table, self.ID, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn)\r
+        Table.Insert(self, SqlCommand)\r
+\r
+        return self.ID
\ No newline at end of file