mORMot and Open Source friends
Check-in [062b595c63]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:{1088} fixed TDynArray.Find() so that it returns the index of the found item in the TDynArray
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 062b595c631e2015d01f34788018cb88effbd620
User & Date: ab 2015-03-17 09:34:45
Context
2015-03-17
11:14
{1089} fixed TWebSocketProtocolJSON.FrameDecompress so that the frame could be provided to another provider if the header does not match check-in: fbe90e9fef user: ab tags: trunk
09:34
{1088} fixed TDynArray.Find() so that it returns the index of the found item in the TDynArray check-in: 062b595c63 user: ab tags: trunk
2015-03-16
21:36
{1087} fixed FPC compilation under Windows check-in: 16be56e4a9 user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SQLite3/mORMot.pas.

2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
....
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
....
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
....
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
....
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
....
7350
7351
7352
7353
7354
7355
7356


7357
7358
7359
7360
7361
7362
7363
....
8038
8039
8040
8041
8042
8043
8044

8045
8046

8047
8048
8049
8050
8051
8052
8053
....
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
.....
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
.....
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
.....
11929
11930
11931
11932
11933
11934
11935

11936
11937
11938
11939
11940
11941
11942
11943
.....
11982
11983
11984
11985
11986
11987
11988

11989
11990
11991
11992
11993
11994
11995
11996
.....
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
.....
12567
12568
12569
12570
12571
12572
12573

12574
12575
12576
12577
12578
12579
12580
12581
.....
12642
12643
12644
12645
12646
12647
12648

12649
12650
12651
12652
12653
12654
12655
.....
14861
14862
14863
14864
14865
14866
14867


14868
14869
14870
14871
14872
14873
14874
    function GetFieldAddr(Instance: TObject): pointer; virtual; abstract;
    /// the corresponding column type, as managed for abstract database access
    function SQLDBFieldType: TSQLDBFieldType;
    /// the corresponding column type name, as managed for abstract database access
    function SQLDBFieldTypeName: PShortString;
  end;

  /// type of a TSQLPropInfo class
  TSQLPropInfoClass = class of TSQLPropInfo;

  /// define how the published properties RTTI is to be interpreted
  // - i.e. how TSQLPropInfoList.Create() and TSQLPropInfoRTTI.CreateFrom()
  // would handle the incoming RTTI
  TSQLPropInfoListOptions = set of (
    pilRaiseEORMExceptionIfNotHandled, pilAllowIDFields,
................................................................................
    property PropInfo: PPropInfo read fPropInfo;
    /// for pilSubClassesFlattening properties, the parents RTTI
    property FlattenedPropInfo: PPropInfoDynArray read fFlattenedProps;
    /// corresponding type information, as retrieved from PropInfo RTTI
    property PropType: PTypeInfo read fPropType;
  end;

  /// type of a TSQLPropInfoRTTI class
  TSQLPropInfoRTTIClass = class of TSQLPropInfoRTTI;

  TSQLPropInfoRTTIObjArray = array of TSQLPropInfoRTTI;

  /// information about an ordinal Int32 published property
  TSQLPropInfoRTTIInt32 = class(TSQLPropInfoRTTI)
  protected
................................................................................
    /// you shall override this abstract method
    class function GetClass: TCollectionItemClass; virtual; abstract;
  public
    /// this constructor which will call GetClass to initialize the collection
    constructor Create; reintroduce; virtual;
  end;

  /// the class of TInterfacedCollection kind
  TInterfacedCollectionClass = class of TInterfacedCollection;

  /// abstract TCollectionItem class, which will instantiate all its nested
  // TPersistent/TSynPersistent class published properties, then release them when freed
  // - could be used for gathering of TCollectionItem properties, e.g. for
  // Domain objects in DDD, especially for list of value objects
  // - note that non published properties won't be instantiated
................................................................................
    /// this overriden constructor will release all its nested
    // TPersistent class published properties
    destructor Destroy; override;
  end;

  {$endif LVCL}

  /// the class of TInterfacedObject kind
  TInterfacedObjectClass = class of TInterfacedObject;

  /// abstract TPersistent class, which will instantiate all its nested TPersistent
  // class published properties, then release them (and any T*ObjArray) when freed
  // - TSynAutoCreateFields is to be preferred in most cases, due to its lower overhead
  // - note that non published (e.g. public) properties won't be instantiated
  // - please take care that you would not create any endless recursion: you
................................................................................

  /// a list of data process statistics
  TSynMonitorWithSizeObjArray = array of TSynMonitorWithSize;

  /// a list of incoming/outgoing data process statistics
  TSynMonitorInputOutputObjArray = array of TSynMonitorInputOutput;

  /// used to store the class of process statistic instances
  TSynMonitorClass = class of TSynMonitor;

const
  /// HTML Status Code for "Continue"
  HTML_CONTINUE = 100;
  /// HTML Status Code for "Switching Protocols"
  HTML_SWITCHINGPROTOCOLS = 101;
................................................................................
  /// parent of all virtual classes
  // - you can define a plain TSQLRecord class as virtual if needed  - e.g.
  // inheriting from TSQLRecordMany then calling VirtualTableExternalRegister() -
  // but using this class will seal its state to be virtual
  TSQLRecordVirtual = class(TSQLRecord);

  TSQLVirtualTable = class;


  TSQLVirtualTableClass = class of TSQLVirtualTable;

  /// pre-computed SQL statements for ORM operations for a given
  // TSQLModelRecordProperties instance
  TSQLModelRecordPropertiesSQL = record
    /// the simple field names in a SQL SELECT compatible format: 'COL1,COL2' e.g.
    // - format is
................................................................................
     property DocID: TID read GetID write fID;
  end;

  /// this base class will create a FTS3 table using the Porter Stemming algorithm
  // - see http://sqlite.org/fts3.html#tokenizer
  TSQLRecordFTS3Porter = class(TSQLRecordFTS3);


  TSQLRecordFTS3Class = class of TSQLRecordFTS3;


  TSQLRecordRTreeClass = class of TSQLRecordRTree;

  {/ a base record, corresdonding to a FTS4 table, which is an enhancement to FTS3
  - FTS3 and FTS4 are nearly identical. They share most of their code in common,
   and their interfaces are the same. The only difference is that FTS4 stores
   some additional information about the document collection in two of new FTS
   shadow tables. This additional information allows FTS4 to use certain
................................................................................
    // - here interfaces and instances are provided as TGUID and pointers
    procedure Resolve(const aInterfaces: array of TGUID; const aObjs: array of pointer); overload;
    /// release all used instances
    // - including all TInterfaceStub instances as specified to CreateInjected()
    destructor Destroy; override;
  end;

  /// defines the class of a TInjectableObject type
  TInjectableObjectClass = class of TInjectableObject;

  /// used to set the published properties of a TInjectableAutoCreateFields
  // - TInjectableAutoCreateFields.Create will check any resolver able to
  // implement this interface, then run its SetProperties() method on it
  IAutoCreateFieldsResolve = interface
    ['{396362E9-B60D-43D4-A0D4-802E4479F24E}']
................................................................................
  /// how a TSQLRest class may execute read or write operations
  // - used e.g. for TSQLRestServer.AcquireWriteMode or
  // TSQLRestServer.AcquireExecutionMode/AcquireExecutionLockedTimeOut
  TSQLRestServerAcquireMode = (
    amUnlocked, amLocked, amBackgroundThread, amBackgroundORMSharedThread
    {$ifndef LVCL}, amMainThread{$endif});

  /// the class of a TSQLRest
  TSQLRestClass = class of TSQLRest;

  /// a dynamic array of TSQLRest instances
  TSQLRestDynArray = array of TSQLRest;

  /// a generic REpresentational State Transfer (REST) client/server class
  TSQLRest = class
................................................................................
      Table: TSQLRecordClass; TableIndex: integer; const TableID: TID;
      Context: TSQLRestServerURIContext): boolean;
  end;

  TSQLRestStorageInMemory = class;
  TSQLVirtualTableModule = class;

  /// class of our abstract table storage
  // - may be e.g. TSQLRestStorageInMemory, TSQLRestStorageInMemoryExternal,
  // TSQLRestStorageExternal or TSQLRestStorageMongoDB
  TSQLRestStorageClass = class of TSQLRestStorage;

  /// class of our TObjectList memory-stored table storage
  // - may be TSQLRestStorageInMemory or TSQLRestStorageInMemoryExternal
  TSQLRestStorageInMemoryClass = class of TSQLRestStorageInMemory;

  {/ table containing the available user access rights for authentication
    - this class should be added to the TSQLModel, together with TSQLAuthUser,
      to allow authentication support
    - you can inherit from it to add your custom properties to each user info:
................................................................................
    property Ident: RawUTF8 index 50 read fIdent write fIdent stored AS_UNIQUE;
    /// the number of minutes a session is kept alive
    property SessionTimeout: integer read fSessionTimeOut write fSessionTimeOut;
    /// a textual representation of a TSQLAccessRights buffer
    property AccessRights: RawUTF8 index 1600 read fAccessRights write fAccessRights;
  end;


  /// class of the table containing the available user access rights for authentication
  TSQLAuthGroupClass = class of TSQLAuthGroup;

  {/ table containing the Users registered for authentication
    - this class should be added to the TSQLModel, together with TSQLAuthGroup,
      to allow authentication support
    - you can inherit from it to add your custom properties to each user info:
      TSQLModel will search for any class inheriting from TSQLAuthUser to manage
................................................................................
    /// some custom data, associated to the User
    // - Server application may store here custom data
    // - its content is not used by the framework but 'may' be used by your
    // application
    property Data: TSQLRawBlob read fData write fData;
  end;


  /// class of the table containing the Users registered for authentication
  TSQLAuthUserClass = class of TSQLAuthUser;

  /// class used to maintain in-memory sessions
  // - this is not a TSQLRecord table so won't be remotely accessible, for
  // performance and security reasons
  // - the User field is a true instance, copy of the corresponding database
  // content (for better speed)
................................................................................
    // - is extracted from SentHeaders properties
    property RemoteIP: RawUTF8 read fRemoteIP;
    /// a remote connection identifier, if any
    // - is extracted from SentHeaders properties
    property ConnectionID: RawUTF8 read fConnectionID;
  end;

  /// used to define overridden session instances
  // - since all sessions data remain in memory, ensure they are not taking too
  // much resource (memory or process time)
  // - if you plan to use session persistence, ensure you override the
  // TAuthSession.SaveTo/CreateFrom methods in the inherited class
  TAuthSessionClass = class of TAuthSession;

  TSQLRestServerAuthentication = class;

  /// used to define an authentication scheme by its implementation class
  TSQLRestServerAuthenticationClass = class of TSQLRestServerAuthentication;

  /// maintain a list of TSQLRestServerAuthentication instances
  TSQLRestServerAuthenticationDynArray = array of TSQLRestServerAuthentication;

  /// define how TSQLRestServerAuthentication.ClientSetUser() should interpret
  // the supplied password
................................................................................
    // a call to CreateHistory() constructor
    // - as any BLOB field, this one won't be retrieved by default: use
    // explicitly TSQLRest.RetrieveBlobFields(aRecordHistory) to get it if you
    // want to access it directly, and not via CreateHistory()
    property History: TSQLRawBlob read fHistory write fHistory;
  end;


  /// specifies the storage table to be used for tracking TSQLRecord changes
  // - you can create your custom type from TSQLRecordHistory, even for a
  // particular table, to split the tracked changes storage in several tables:
  // ! type
  // !  TSQLRecordMyHistory = class(TSQLRecordHistory);
  // - as expected by TSQLRestServer.TrackChanges() method 
  TSQLRecordHistoryClass = class of TSQLRecordHistory;

................................................................................
    property Read: QWord read fRead;
    /// how many Update ORM operations did take place
    property Updated: QWord read fUpdated;
    /// how many Delete ORM operations did take place
    property Deleted: QWord read fDeleted;
  end;


  TSQLRestServerClass = class of TSQLRestServer;

  /// a generic REpresentational State Transfer (REST) server
  // - descendent must implement the protected EngineList() Retrieve() Add()
  // Update() Delete() methods
  // - automatic call of this methods by a generic URI() RESTful function
  // - any published method of descendants must match TSQLRestServerCallBack
................................................................................
    function IsWhereOneFieldEquals: boolean;
       {$ifdef HASINLINE}inline;{$endif}
  end;

  PSQLVirtualTablePrepared = ^TSQLVirtualTablePrepared;

  TSQLVirtualTableCursor = class;


  TSQLVirtualTableCursorClass = class of TSQLVirtualTableCursor;

  /// the possible features of a Virtual Table
  // - vtWrite is to be set if the table is not Read/Only
  // - vtTransaction if handles vttBegin, vttSync, vttCommit, vttRollBack
  // - vtSavePoint if handles vttSavePoint, vttRelease, vttRollBackTo
  // - vtWhereIDPrepared if the ID=? WHERE statement will be handled in






|







 







|







 







|







 







|







 







|







 







>
>







 







>


>







 







|







 







|







 







|




|







 







>
|







 







>
|







 







|








|







 







>
|







 







>







 







>
>







2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
....
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
....
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
....
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
....
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
....
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
....
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
....
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
.....
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
.....
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
.....
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
.....
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
.....
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
.....
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
.....
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
.....
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
    function GetFieldAddr(Instance: TObject): pointer; virtual; abstract;
    /// the corresponding column type, as managed for abstract database access
    function SQLDBFieldType: TSQLDBFieldType;
    /// the corresponding column type name, as managed for abstract database access
    function SQLDBFieldTypeName: PShortString;
  end;

  /// class-reference type (metaclass) of a TSQLPropInfo information 
  TSQLPropInfoClass = class of TSQLPropInfo;

  /// define how the published properties RTTI is to be interpreted
  // - i.e. how TSQLPropInfoList.Create() and TSQLPropInfoRTTI.CreateFrom()
  // would handle the incoming RTTI
  TSQLPropInfoListOptions = set of (
    pilRaiseEORMExceptionIfNotHandled, pilAllowIDFields,
................................................................................
    property PropInfo: PPropInfo read fPropInfo;
    /// for pilSubClassesFlattening properties, the parents RTTI
    property FlattenedPropInfo: PPropInfoDynArray read fFlattenedProps;
    /// corresponding type information, as retrieved from PropInfo RTTI
    property PropType: PTypeInfo read fPropType;
  end;

  /// class-reference type (metaclass) of a TSQLPropInfoRTTI information
  TSQLPropInfoRTTIClass = class of TSQLPropInfoRTTI;

  TSQLPropInfoRTTIObjArray = array of TSQLPropInfoRTTI;

  /// information about an ordinal Int32 published property
  TSQLPropInfoRTTIInt32 = class(TSQLPropInfoRTTI)
  protected
................................................................................
    /// you shall override this abstract method
    class function GetClass: TCollectionItemClass; virtual; abstract;
  public
    /// this constructor which will call GetClass to initialize the collection
    constructor Create; reintroduce; virtual;
  end;

  /// class-reference type (metaclass) of a TInterfacedCollection kind
  TInterfacedCollectionClass = class of TInterfacedCollection;

  /// abstract TCollectionItem class, which will instantiate all its nested
  // TPersistent/TSynPersistent class published properties, then release them when freed
  // - could be used for gathering of TCollectionItem properties, e.g. for
  // Domain objects in DDD, especially for list of value objects
  // - note that non published properties won't be instantiated
................................................................................
    /// this overriden constructor will release all its nested
    // TPersistent class published properties
    destructor Destroy; override;
  end;

  {$endif LVCL}

  /// class-reference type (metaclass) of a TInterfacedObject kind
  TInterfacedObjectClass = class of TInterfacedObject;

  /// abstract TPersistent class, which will instantiate all its nested TPersistent
  // class published properties, then release them (and any T*ObjArray) when freed
  // - TSynAutoCreateFields is to be preferred in most cases, due to its lower overhead
  // - note that non published (e.g. public) properties won't be instantiated
  // - please take care that you would not create any endless recursion: you
................................................................................

  /// a list of data process statistics
  TSynMonitorWithSizeObjArray = array of TSynMonitorWithSize;

  /// a list of incoming/outgoing data process statistics
  TSynMonitorInputOutputObjArray = array of TSynMonitorInputOutput;

  /// class-reference type (metaclass) of a process statistic information
  TSynMonitorClass = class of TSynMonitor;

const
  /// HTML Status Code for "Continue"
  HTML_CONTINUE = 100;
  /// HTML Status Code for "Switching Protocols"
  HTML_SWITCHINGPROTOCOLS = 101;
................................................................................
  /// parent of all virtual classes
  // - you can define a plain TSQLRecord class as virtual if needed  - e.g.
  // inheriting from TSQLRecordMany then calling VirtualTableExternalRegister() -
  // but using this class will seal its state to be virtual
  TSQLRecordVirtual = class(TSQLRecord);

  TSQLVirtualTable = class;

  /// class-reference type (metaclass) of a virtual table implementation
  TSQLVirtualTableClass = class of TSQLVirtualTable;

  /// pre-computed SQL statements for ORM operations for a given
  // TSQLModelRecordProperties instance
  TSQLModelRecordPropertiesSQL = record
    /// the simple field names in a SQL SELECT compatible format: 'COL1,COL2' e.g.
    // - format is
................................................................................
     property DocID: TID read GetID write fID;
  end;

  /// this base class will create a FTS3 table using the Porter Stemming algorithm
  // - see http://sqlite.org/fts3.html#tokenizer
  TSQLRecordFTS3Porter = class(TSQLRecordFTS3);

  /// class-reference type (metaclass) of a FTS3/FTS4 virtual table
  TSQLRecordFTS3Class = class of TSQLRecordFTS3;

  /// class-reference type (metaclass) of a RTREE virtual table
  TSQLRecordRTreeClass = class of TSQLRecordRTree;

  {/ a base record, corresdonding to a FTS4 table, which is an enhancement to FTS3
  - FTS3 and FTS4 are nearly identical. They share most of their code in common,
   and their interfaces are the same. The only difference is that FTS4 stores
   some additional information about the document collection in two of new FTS
   shadow tables. This additional information allows FTS4 to use certain
................................................................................
    // - here interfaces and instances are provided as TGUID and pointers
    procedure Resolve(const aInterfaces: array of TGUID; const aObjs: array of pointer); overload;
    /// release all used instances
    // - including all TInterfaceStub instances as specified to CreateInjected()
    destructor Destroy; override;
  end;

  /// class-reference type (metaclass) of a TInjectableObject type
  TInjectableObjectClass = class of TInjectableObject;

  /// used to set the published properties of a TInjectableAutoCreateFields
  // - TInjectableAutoCreateFields.Create will check any resolver able to
  // implement this interface, then run its SetProperties() method on it
  IAutoCreateFieldsResolve = interface
    ['{396362E9-B60D-43D4-A0D4-802E4479F24E}']
................................................................................
  /// how a TSQLRest class may execute read or write operations
  // - used e.g. for TSQLRestServer.AcquireWriteMode or
  // TSQLRestServer.AcquireExecutionMode/AcquireExecutionLockedTimeOut
  TSQLRestServerAcquireMode = (
    amUnlocked, amLocked, amBackgroundThread, amBackgroundORMSharedThread
    {$ifndef LVCL}, amMainThread{$endif});

  /// class-reference type (metaclass) of a TSQLRest kind
  TSQLRestClass = class of TSQLRest;

  /// a dynamic array of TSQLRest instances
  TSQLRestDynArray = array of TSQLRest;

  /// a generic REpresentational State Transfer (REST) client/server class
  TSQLRest = class
................................................................................
      Table: TSQLRecordClass; TableIndex: integer; const TableID: TID;
      Context: TSQLRestServerURIContext): boolean;
  end;

  TSQLRestStorageInMemory = class;
  TSQLVirtualTableModule = class;

  /// class-reference type (metaclass) of our abstract table storage
  // - may be e.g. TSQLRestStorageInMemory, TSQLRestStorageInMemoryExternal,
  // TSQLRestStorageExternal or TSQLRestStorageMongoDB
  TSQLRestStorageClass = class of TSQLRestStorage;

  /// class-reference type (metaclass) of our TObjectList memory-stored table storage
  // - may be TSQLRestStorageInMemory or TSQLRestStorageInMemoryExternal
  TSQLRestStorageInMemoryClass = class of TSQLRestStorageInMemory;

  {/ table containing the available user access rights for authentication
    - this class should be added to the TSQLModel, together with TSQLAuthUser,
      to allow authentication support
    - you can inherit from it to add your custom properties to each user info:
................................................................................
    property Ident: RawUTF8 index 50 read fIdent write fIdent stored AS_UNIQUE;
    /// the number of minutes a session is kept alive
    property SessionTimeout: integer read fSessionTimeOut write fSessionTimeOut;
    /// a textual representation of a TSQLAccessRights buffer
    property AccessRights: RawUTF8 index 1600 read fAccessRights write fAccessRights;
  end;

  /// class-reference type (metaclass) of the table containing the available
  // user access rights for authentication, defined as a group
  TSQLAuthGroupClass = class of TSQLAuthGroup;

  {/ table containing the Users registered for authentication
    - this class should be added to the TSQLModel, together with TSQLAuthGroup,
      to allow authentication support
    - you can inherit from it to add your custom properties to each user info:
      TSQLModel will search for any class inheriting from TSQLAuthUser to manage
................................................................................
    /// some custom data, associated to the User
    // - Server application may store here custom data
    // - its content is not used by the framework but 'may' be used by your
    // application
    property Data: TSQLRawBlob read fData write fData;
  end;

  /// class-reference type (metaclass) of a table containing the Users
  // registered for authentication
  TSQLAuthUserClass = class of TSQLAuthUser;

  /// class used to maintain in-memory sessions
  // - this is not a TSQLRecord table so won't be remotely accessible, for
  // performance and security reasons
  // - the User field is a true instance, copy of the corresponding database
  // content (for better speed)
................................................................................
    // - is extracted from SentHeaders properties
    property RemoteIP: RawUTF8 read fRemoteIP;
    /// a remote connection identifier, if any
    // - is extracted from SentHeaders properties
    property ConnectionID: RawUTF8 read fConnectionID;
  end;

  /// class-reference type (metaclass) used to define overridden session instances
  // - since all sessions data remain in memory, ensure they are not taking too
  // much resource (memory or process time)
  // - if you plan to use session persistence, ensure you override the
  // TAuthSession.SaveTo/CreateFrom methods in the inherited class
  TAuthSessionClass = class of TAuthSession;

  TSQLRestServerAuthentication = class;

  /// class-reference type (metaclass) used to define an authentication scheme
  TSQLRestServerAuthenticationClass = class of TSQLRestServerAuthentication;

  /// maintain a list of TSQLRestServerAuthentication instances
  TSQLRestServerAuthenticationDynArray = array of TSQLRestServerAuthentication;

  /// define how TSQLRestServerAuthentication.ClientSetUser() should interpret
  // the supplied password
................................................................................
    // a call to CreateHistory() constructor
    // - as any BLOB field, this one won't be retrieved by default: use
    // explicitly TSQLRest.RetrieveBlobFields(aRecordHistory) to get it if you
    // want to access it directly, and not via CreateHistory()
    property History: TSQLRawBlob read fHistory write fHistory;
  end;

  /// class-reference type (metaclass) to specify the storage table to be used
  // for tracking TSQLRecord changes
  // - you can create your custom type from TSQLRecordHistory, even for a
  // particular table, to split the tracked changes storage in several tables:
  // ! type
  // !  TSQLRecordMyHistory = class(TSQLRecordHistory);
  // - as expected by TSQLRestServer.TrackChanges() method 
  TSQLRecordHistoryClass = class of TSQLRecordHistory;

................................................................................
    property Read: QWord read fRead;
    /// how many Update ORM operations did take place
    property Updated: QWord read fUpdated;
    /// how many Delete ORM operations did take place
    property Deleted: QWord read fDeleted;
  end;

  /// class-reference type (metaclass) of a REST server
  TSQLRestServerClass = class of TSQLRestServer;

  /// a generic REpresentational State Transfer (REST) server
  // - descendent must implement the protected EngineList() Retrieve() Add()
  // Update() Delete() methods
  // - automatic call of this methods by a generic URI() RESTful function
  // - any published method of descendants must match TSQLRestServerCallBack
................................................................................
    function IsWhereOneFieldEquals: boolean;
       {$ifdef HASINLINE}inline;{$endif}
  end;

  PSQLVirtualTablePrepared = ^TSQLVirtualTablePrepared;

  TSQLVirtualTableCursor = class;

  /// class-reference type (metaclass) of a cursor on an abstract Virtual Table
  TSQLVirtualTableCursorClass = class of TSQLVirtualTableCursor;

  /// the possible features of a Virtual Table
  // - vtWrite is to be set if the table is not Read/Only
  // - vtTransaction if handles vttBegin, vttSync, vttCommit, vttRollBack
  // - vtSavePoint if handles vttSavePoint, vttRelease, vttRollBackTo
  // - vtWhereIDPrepared if the ID=? WHERE statement will be handled in

Changes to SQLite3/mORMotMVC.pas.

1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
    if (Mustache=nil) and (FileName='') then
      raise EMVCException.CreateUTF8('%.Render(''%''): Missing Template in ''%''',
        [self,MethodName,SearchPattern]);
    if (Mustache=nil) or ((fViewTemplateFileTimestampMonitor<>0) and
       (FileTimeStampCheckTick<GetTickCount64)) then begin
      age := FileAgeToDateTime(FileName);
      if (Mustache=nil) or (age<>FileTimeStamp) then begin
        Mustache := nil;
        FileTimeStamp := age;
        Template := AnyTextFileToRawUTF8(FileName,true);
        if Template<>'' then
        try
          Mustache := TSynMustache.Parse(Template);
        except
          on E: Exception do






|







1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
    if (Mustache=nil) and (FileName='') then
      raise EMVCException.CreateUTF8('%.Render(''%''): Missing Template in ''%''',
        [self,MethodName,SearchPattern]);
    if (Mustache=nil) or ((fViewTemplateFileTimestampMonitor<>0) and
       (FileTimeStampCheckTick<GetTickCount64)) then begin
      age := FileAgeToDateTime(FileName);
      if (Mustache=nil) or (age<>FileTimeStamp) then begin
        Mustache := nil; // no Mustache.Free: TSynMustache instances are cached
        FileTimeStamp := age;
        Template := AnyTextFileToRawUTF8(FileName,true);
        if Template<>'' then
        try
          Mustache := TSynMustache.Parse(Template);
        except
          on E: Exception do

Changes to SQLite3/mORMotSQLite3.pas.

313
314
315
316
317
318
319

320
321
322
323
324
325
326
    //   value: our JSON parsing is a lot faster than SQLite3 engine itself,
    //   and uses less memory
    // - will raise an ESQLException on any error 
    constructor Create(aDB: TSQLDatabase; const Tables: array of TSQLRecordClass;
      const aSQL: RawUTF8; Expand: boolean); reintroduce;
  end;


  TSQLRestServerDBClass = class of TSQLRestServerDB;

  TSQLVirtualTableModuleServerDB = class;

  /// REST server with direct access to a SQLite3 database
  // - caching is handled at TSQLDatabase level
  // - SQL statements for record retrieval from ID are prepared for speed






>







313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
    //   value: our JSON parsing is a lot faster than SQLite3 engine itself,
    //   and uses less memory
    // - will raise an ESQLException on any error 
    constructor Create(aDB: TSQLDatabase; const Tables: array of TSQLRecordClass;
      const aSQL: RawUTF8; Expand: boolean); reintroduce;
  end;

  /// class-reference type (metaclass) of a REST server using SQLite3 as main engine
  TSQLRestServerDBClass = class of TSQLRestServerDB;

  TSQLVirtualTableModuleServerDB = class;

  /// REST server with direct access to a SQLite3 database
  // - caching is handled at TSQLDatabase level
  // - SQL statements for record retrieval from ID are prepared for speed

Changes to SynCommons.pas.

7650
7651
7652
7653
7654
7655
7656

7657
7658
7659
7660
7661
7662
7663
.....
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
.....
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
.....
32271
32272
32273
32274
32275
32276
32277
32278
32279
32280
32281
32282
32283
32284

32285

32286
32287
32288
32289
32290
32291
32292
  public
    /// perform the filtering action to the specified value
    // - the value is converted into UTF-8 text, as expected by
    // TPropInfo.GetValue / TPropInfo.SetValue e.g.
    procedure Process(aFieldIndex: integer; var Value: RawUTF8); virtual; abstract;
  end;


  TSynFilterClass = class of TSynFilter;

  /// a custom filter which will convert the value into Upper Case characters
  // - UpperCase conversion is made for ASCII-7 only, i.e. 'a'..'z' characters
  // - this version expects no parameter
  TSynFilterUpperCase = class(TSynFilter)
  public
................................................................................
    /// clear the content
    procedure Clear(var V: TVarData); override;
    /// copy two record content
    procedure Copy(var Dest: TVarData; const Source: TVarData;
      const Indirect: Boolean); override;
  end;

  /// class of custom variant type definition
  // - used by SynRegisterCustomVariantType() function
  TSynInvokeableVariantTypeClass = class of TSynInvokeableVariantType;

/// register a custom variant type to handle properties
// - this will implement an internal mechanism used to bypass the default
// _DispInvoke() implementation in Variant.pas, to use a faster version
// - is called in case of TSynTableVariant, TDocVariant, TBSONVariant or
................................................................................
    // - result variant is returned as a copy, not as varByRef, since a copy
    // will definitively be more thread safe
    property Value[const Name: RawUTF8]: Variant read GetValue write SetValue; default;
  end;
{$endif}
{$endif}

  /// used to refer to a simple authentication class
  TSynAuthenticationClass = class of TSynAuthenticationAbstract;

  /// abstract authentication class, implementing safe token/challenge security
  // and a list of active sessions
  // - do not use this class, but plain TSynAuthentication
  TSynAuthenticationAbstract = class
  protected
................................................................................
var n, L, cmp: integer;
    P: PAnsiChar;
begin
  n := Count;
  if (@aCompare<>nil) and (n>0) then begin
    dec(n);
    P := fValue^;
    if (n>10) and (length(aIndex)>n) then begin
      // array should be sorted -> use fast binary search
      L := 0;
      repeat
        result := (L+n) shr 1;
        cmp := aCompare(P[cardinal(aIndex[result])*ElemSize],Elem);
        if cmp=0 then

          exit;

        if cmp<0 then
          L := result+1 else
          n := result-1;
      until L>n;
    end else
      // array is not sorted -> use iterating search
      for result := 0 to n do






>







 







|







 







|







 







|
|




|
>

>







7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
.....
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
.....
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
.....
32272
32273
32274
32275
32276
32277
32278
32279
32280
32281
32282
32283
32284
32285
32286
32287
32288
32289
32290
32291
32292
32293
32294
32295
  public
    /// perform the filtering action to the specified value
    // - the value is converted into UTF-8 text, as expected by
    // TPropInfo.GetValue / TPropInfo.SetValue e.g.
    procedure Process(aFieldIndex: integer; var Value: RawUTF8); virtual; abstract;
  end;

  /// class-reference type (metaclass) of a record filter 
  TSynFilterClass = class of TSynFilter;

  /// a custom filter which will convert the value into Upper Case characters
  // - UpperCase conversion is made for ASCII-7 only, i.e. 'a'..'z' characters
  // - this version expects no parameter
  TSynFilterUpperCase = class(TSynFilter)
  public
................................................................................
    /// clear the content
    procedure Clear(var V: TVarData); override;
    /// copy two record content
    procedure Copy(var Dest: TVarData; const Source: TVarData;
      const Indirect: Boolean); override;
  end;

  /// class-reference type (metaclass) of custom variant type definition
  // - used by SynRegisterCustomVariantType() function
  TSynInvokeableVariantTypeClass = class of TSynInvokeableVariantType;

/// register a custom variant type to handle properties
// - this will implement an internal mechanism used to bypass the default
// _DispInvoke() implementation in Variant.pas, to use a faster version
// - is called in case of TSynTableVariant, TDocVariant, TBSONVariant or
................................................................................
    // - result variant is returned as a copy, not as varByRef, since a copy
    // will definitively be more thread safe
    property Value[const Name: RawUTF8]: Variant read GetValue write SetValue; default;
  end;
{$endif}
{$endif}

  /// class-reference type (metaclass) of an authentication class
  TSynAuthenticationClass = class of TSynAuthenticationAbstract;

  /// abstract authentication class, implementing safe token/challenge security
  // and a list of active sessions
  // - do not use this class, but plain TSynAuthentication
  TSynAuthenticationAbstract = class
  protected
................................................................................
var n, L, cmp: integer;
    P: PAnsiChar;
begin
  n := Count;
  if (@aCompare<>nil) and (n>0) then begin
    dec(n);
    P := fValue^;
    if (n>10) and (length(aIndex)>=n) then begin
      // array should be sorted via aIndex[] -> use fast binary search
      L := 0;
      repeat
        result := (L+n) shr 1;
        cmp := aCompare(P[cardinal(aIndex[result])*ElemSize],Elem);
        if cmp=0 then begin
          result := aIndex[result]; // returns index in TDynArray
          exit;
        end;
        if cmp<0 then
          L := result+1 else
          n := result-1;
      until L>n;
    end else
      // array is not sorted -> use iterating search
      for result := 0 to n do

Changes to SynLog.pas.

216
217
218
219
220
221
222






223

224
225
226
227
228
229
230
    property HasDebugInfo: boolean read fHasDebugInfo;
  end;
  {$M-}

  {$M+} { we need the RTTI for the published methods of the logging classes }

  TSynLog = class;






  TSynLogClass = class of TSynLog;

  TSynLogFamily = class;
  TSynLogFile = class;
  
  {$M-}

  /// a generic interface used for logging a method
  // - you should create one TSynLog instance at the beginning of a block code






>
>
>
>
>
>

>







216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
    property HasDebugInfo: boolean read fHasDebugInfo;
  end;
  {$M-}

  {$M+} { we need the RTTI for the published methods of the logging classes }

  TSynLog = class;

  /// class-reference type (metaclass) of a TSynLog family
  // - since TSynLog classes store their information per type, you usually
  // will store a reference to a logging family (i.e. logging settings) using
  // a TSynLogClass variable, whereas TSynLog would point to the active logging
  // instance
  TSynLogClass = class of TSynLog;

  TSynLogFamily = class;
  TSynLogFile = class;
  
  {$M-}

  /// a generic interface used for logging a method
  // - you should create one TSynLog instance at the beginning of a block code

Changes to SynTests.pas.

246
247
248
249
250
251
252

253
254
255
256
257
258
259
    /// the index of the test case, starting at 0 for the associated MethodIndex
    property TestCaseIndex: integer read fTestCaseIndex;
  published
    { all published methods of the children will be run as individual tests
      - these methods must be declared as procedure with no parameter }
  end;


  TSynTestCaseClass = class of TSynTestCase;

  /// a class used to run a suit of test cases
  TSynTests = class(TSynTest)
  protected
    /// any number not null assigned to this field will display a "../sec" stat
    fRunConsoleOccurenceNumber: cardinal;






>







246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
    /// the index of the test case, starting at 0 for the associated MethodIndex
    property TestCaseIndex: integer read fTestCaseIndex;
  published
    { all published methods of the children will be run as individual tests
      - these methods must be declared as procedure with no parameter }
  end;

  /// class-reference type (metaclass) of a test case
  TSynTestCaseClass = class of TSynTestCase;

  /// a class used to run a suit of test cases
  TSynTests = class(TSynTest)
  protected
    /// any number not null assigned to this field will display a "../sec" stat
    fRunConsoleOccurenceNumber: cardinal;

Changes to SynopseCommit.inc.

1
'1.18.1087'
|
1
'1.18.1088'