Skip to content

Commit

Permalink
iOS Compatibility
Browse files Browse the repository at this point in the history
iOS compatibility added. Project all set for Xojo 2016r3.
  • Loading branch information
pjzedalis committed Sep 10, 2016
1 parent 2db0c17 commit 98d566a
Show file tree
Hide file tree
Showing 8 changed files with 717 additions and 48 deletions.
Binary file removed .SQLdeLite.xojo_uistate
Binary file not shown.
Binary file added Examples/Chinook_Sqlite.sqlite
Binary file not shown.
Binary file added Examples/iOS_SQLite.xojo_binary_project
Binary file not shown.
Binary file added Source/.SQLdeLite.xojo_uistate
Binary file not shown.
603 changes: 558 additions & 45 deletions Source/SQLdeLite.xojo_code

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Source/SQLdeLite.xojo_project
@@ -1,12 +1,12 @@
Type=Desktop
RBProjectVersion=2015.041
RBProjectVersion=2016.03
MinIDEVersion=20070100
Class=Record;SQLdeLite/Record.xojo_code;&h5A2367FF;&h332D3FFF;false
Class=App;App.xojo_code;&h36F27FFF;&h0;false
Window=Window1;Window1.xojo_window;&h4BD4EFFF;&h0;false
MenuBar=MainMenuBar;MainMenuBar.xojo_menu;&h6E9667FF;&h0;false
Module=SQLdeLite;SQLdeLite.xojo_code;&h637227FF;&h0;false
Module=SQLdeLite;SQLdeLite.xojo_code;&h332D3FFF;&h0;false
BuildSteps=Build Automation;Build Automation.xojo_code;&h1566BFFF;&h0;false
Class=Record;SQLdeLite/Record.xojo_code;&h38706FFF;&h637227FF;false
DefaultWindow=Window1
AppMenuBar=MainMenuBar
MajorVersion=1
Expand Down Expand Up @@ -39,3 +39,4 @@ DebuggerCommandLine=
UseGDIPlus=False
UseBuildsFolder=True
IsWebProject=False
OptimizationLevel=0
155 changes: 155 additions & 0 deletions Source/SQLdeLite/Record.xojo_code
Expand Up @@ -8,12 +8,167 @@ Protected Class Record
End Sub
#tag EndMethod

#tag Method, Flags = &h0
Function CreateInsertStatement(db As Object, TableName As Text, TableAndFieldNamesQuoted As Boolean = True) As Text
// Determine what database engine we are on.
Dim _info As Xojo.Introspection.TypeInfo
_info = Xojo.Introspection.GetType(me)

// Create array to hold INSERT statement
Dim _sql() As Text

_sql.Append("INSERT INTO ")
If (TableAndFieldNamesQuoted = True) Then
_sql.Append("""")
End If
_sql.Append(TableName)
If (TableAndFieldNamesQuoted = True) Then
_sql.Append("""")
End If
_sql.Append(" (")

// Loop through the properties of Record
For Each _entry As Xojo.Core.DictionaryEntry In Record.GetIterator()

If (TableAndFieldNamesQuoted = True) Then
_sql.Append("""")
End If
_sql.Append(_entry.Key)
If (TableAndFieldNamesQuoted = True) Then
_sql.Append("""")
End If
_sql.Append(", ")

Next

// Remove trailing comma.
_sql.Remove(_sql.Ubound)

// Write out the values.
_sql.Append(") VALUES (")

// Loop through the properties of Record
For Each _entry As Xojo.Core.DictionaryEntry In Record.GetIterator()

// Verify the entry has a value.
If (_entry.Value = Nil) Then

_sql.Append("NULL")

Else

// Find the type of the value
Dim __entryInfo As Xojo.Introspection.TypeInfo
__entryInfo = Xojo.Introspection.GetType(_entry.Value)

If (__entryInfo.FullName = "Int32") Then
Dim __temp As Int32
__temp = _entry.Value
_sql.Append(__temp.ToText())
ElseIf (__entryInfo.FullName = "Int64") Then
Dim __temp As Int64
__temp = _entry.Value
_sql.Append(__temp.ToText())
ElseIf (__entryInfo.FullName = "Integer") Then
Dim __temp As Integer
__temp = _entry.Value
_sql.Append(__temp.ToText())
ElseIf (__entryInfo.FullName = "Double") Then
Dim __temp As Double
__temp = _entry.Value
_sql.Append(__temp.ToText())
ElseIf (__entryInfo.FullName = "String") Then
#If TargetIOS = False Then
Dim __temp As String
__temp = _entry.Value
_sql.Append("'")
_sql.Append(DefineEncoding(__temp, Encodings.UTF8).ToText())
_sql.Append("'")
#EndIf
ElseIf (__entryInfo.FullName = "Text") Then
Dim __temp As Text
__temp = _entry.Value
_sql.Append("'")
_sql.Append(__temp)
_sql.Append("'")
End If

End If

_sql.Append(", ")

Next

// Loop through the public properties of the Record object (potential sub-class) to bind any properties.
Dim _recordInfo As Xojo.Introspection.TypeInfo
_recordInfo = Xojo.Introspection.GetType(me)

For Each _property As Xojo.Introspection.PropertyInfo In _recordInfo.Properties

// Determine if the property is public.
If (_property.IsPublic = True) Then

// Find the type of the value
Dim __entryInfo As Xojo.Introspection.TypeInfo
__entryInfo = Xojo.Introspection.GetType(_property)

If (__entryInfo.FullName = "Int32") Then
Dim __temp As Int32
__temp = _property.Value(me)
_sql.Append(__temp.ToText())
ElseIf (__entryInfo.FullName = "Int64") Then
Dim __temp As Int64
__temp = _property.Value(me)
_sql.Append(__temp.ToText())
ElseIf (__entryInfo.FullName = "Integer") Then
Dim __temp As Integer
__temp = _property.Value(me)
_sql.Append(__temp.ToText())
ElseIf (__entryInfo.FullName = "Double") Then
Dim __temp As Double
__temp = _property.Value(me)
_sql.Append(__temp.ToText())
ElseIf (__entryInfo.FullName = "String") Then
#If TargetIOS = False Then
Dim __temp As String
__temp = _property.Value(me)
_sql.Append(DefineEncoding(__temp, Encodings.UTF8).ToText().ReplaceAll("'", "''"))
#EndIf
ElseIf (__entryInfo.FullName = "Text") Then
Dim __temp As Text
__temp = _property.Value(me)
_sql.Append(__temp.ReplaceAll("'", "''"))
End If
_sql.Append(", ")

End If

Next

// Remove trailing comma.
_sql.Remove(_sql.Ubound)

// Close the INSERT statement
_sql.Append(")")

// Return the INSERT statement
Return Text.Join(_sql, "")

End Function
#tag EndMethod

#tag Method, Flags = &h0
Function GetIterator() As Xojo.Core.Dictionary
Return pDictionary_Properties
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function GetProperty(Name As Text) As Auto
Return pDictionary_Properties.Value(Name)
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function Operator_Lookup(Name As Text) As Auto
If (pDictionary_Properties.HasKey(Name)) Then
Expand Down
Binary file not shown.

0 comments on commit 98d566a

Please sign in to comment.