mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 07:45:54 +01:00
Nullable Templates
This commit is contained in:
parent
2c6552276e
commit
36c2a2201e
19
.gitignore
vendored
19
.gitignore
vendored
@ -75,3 +75,22 @@ __pycache__/
|
||||
*.bmp
|
||||
samples/renders/bin/uploadedfiles/
|
||||
samples/winecellarclient_mobile/Android/
|
||||
samples/data/activerecorddb.db-journal
|
||||
packages/d103/dmvcframework_group.groupproj.unused
|
||||
lib/loggerpro/unittests/Win32/PLAINDUNITX/
|
||||
samples/winecellarclient_mobile/WinesClient/classes/classes.dex
|
||||
samples/winecellarclient_mobile/WinesClient/library/lib/armeabi-v7a/gdbserver
|
||||
samples/winecellarclient_mobile/WinesClient/res/drawable/splash_image_def.xml
|
||||
samples/winecellarclient_mobile/WinesClient/res/drawable-hdpi/ic_launcher.png
|
||||
samples/winecellarclient_mobile/WinesClient/res/drawable-large/splash_image.png
|
||||
samples/winecellarclient_mobile/WinesClient/res/drawable-ldpi/ic_launcher.png
|
||||
samples/winecellarclient_mobile/WinesClient/res/drawable-mdpi/ic_launcher.png
|
||||
samples/winecellarclient_mobile/WinesClient/res/drawable-normal/splash_image.png
|
||||
samples/winecellarclient_mobile/WinesClient/res/drawable-small/splash_image.png
|
||||
samples/winecellarclient_mobile/WinesClient/res/drawable-xhdpi/ic_launcher.png
|
||||
samples/winecellarclient_mobile/WinesClient/res/drawable-xlarge/splash_image.png
|
||||
samples/winecellarclient_mobile/WinesClient/res/drawable-xxhdpi/ic_launcher.png
|
||||
samples/winecellarclient_mobile/WinesClient/res/values/styles.xml
|
||||
samples/winecellarclient_mobile/WinesClient/AndroidManifest.xml
|
||||
unittests/serializer/jsondataobjects/Win32/CI/dunitx-results.xml
|
||||
unittests/serializer/jsondataobjects/Win32/Debug/dunitx-results.xml
|
||||
|
18
.vscode/launch.json
vendored
Normal file
18
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python TASK generate-nullable",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"module": "invoke",
|
||||
"args": [
|
||||
"generate-nullables"
|
||||
],
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
}
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"python.pythonPath": "venv\\Scripts\\python.exe"
|
||||
}
|
@ -110,7 +110,6 @@
|
||||
<DCC_RemoteDebug>true</DCC_RemoteDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
|
||||
<Debugger_HostApplication>C:\DEV\dmvcframework\samples\activerecord_showcase\bin\activerecord_showcase.exe</Debugger_HostApplication>
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<DCC_MapFile>3</DCC_MapFile>
|
||||
|
150
sources/MVCFramework.Nullables.pas.template
Normal file
150
sources/MVCFramework.Nullables.pas.template
Normal file
@ -0,0 +1,150 @@
|
||||
// ***************************************************************************
|
||||
//
|
||||
// THIS FILE IS GENERATED BY "inv generate-nullables" DO NOT CHANGE MANUALLY!
|
||||
//
|
||||
// ***************************************************************************
|
||||
//
|
||||
// *************************************************************************** }
|
||||
//
|
||||
// Delphi MVC Framework
|
||||
//
|
||||
// Copyright (c) 2010-2020 Daniele Teti and the DMVCFramework Team
|
||||
//
|
||||
// https://github.com/danieleteti/delphimvcframework
|
||||
//
|
||||
// ***************************************************************************
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
unit MVCFramework.Nullables;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
System.SysUtils, System.Classes;
|
||||
|
||||
type
|
||||
EMVCNullable = class(Exception)
|
||||
|
||||
end;
|
||||
|
||||
///INTERFACE.BEGIN
|
||||
Nullable$TYPE$ = record
|
||||
private
|
||||
fValue: $TYPE$;
|
||||
fHasValue: String;
|
||||
function GetHasValue: Boolean;
|
||||
public
|
||||
procedure CheckHasValue;
|
||||
function GetValue: $TYPE$;
|
||||
procedure SetValue(const Value: $TYPE$);
|
||||
class operator Implicit(const Value: $TYPE$): Nullable$TYPE$;
|
||||
class operator Implicit(const Value: Nullable$TYPE$): $TYPE$;
|
||||
property HasValue: Boolean read GetHasValue;
|
||||
///<summary>
|
||||
///Alias of `SetNull`
|
||||
///</summary>
|
||||
procedure Clear;
|
||||
///<summary>
|
||||
///Set the value to `null`
|
||||
///</summary>
|
||||
procedure SetNull;
|
||||
///<summary>
|
||||
///Returns the value stored or the default value for the type is the value is not set
|
||||
///</summary>
|
||||
function ValueOrDefault: $TYPE$;
|
||||
/// <summary>
|
||||
/// Returns true is both item have the same value and that value is not null.
|
||||
/// </summary>
|
||||
function Equals(const Value: Nullable$TYPE$): Boolean;
|
||||
///<summary>
|
||||
///Returns the value stored or raises exception if no value is stored
|
||||
///</summary>
|
||||
property Value: $TYPE$ read GetValue write SetValue;
|
||||
end;
|
||||
|
||||
///INTERFACE.END
|
||||
|
||||
implementation
|
||||
|
||||
///IMPLEMENTATION.BEGIN
|
||||
|
||||
{ Nullable$TYPE$ }
|
||||
|
||||
procedure Nullable$TYPE$.CheckHasValue;
|
||||
begin
|
||||
if not GetHasValue then
|
||||
begin
|
||||
raise EMVCNullable.Create('Value is null');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Nullable$TYPE$.Clear;
|
||||
begin
|
||||
SetNull;
|
||||
end;
|
||||
|
||||
function Nullable$TYPE$.Equals(const Value: Nullable$TYPE$): Boolean;
|
||||
begin
|
||||
Result := (Self.HasValue and Value.HasValue) and (Self.Value = Value.Value);
|
||||
end;
|
||||
|
||||
function Nullable$TYPE$.GetHasValue: Boolean;
|
||||
begin
|
||||
Result := fHasValue = '_';
|
||||
end;
|
||||
|
||||
function Nullable$TYPE$.GetValue: $TYPE$;
|
||||
begin
|
||||
CheckHasValue;
|
||||
Result := fValue;
|
||||
end;
|
||||
|
||||
class operator Nullable$TYPE$.Implicit(const Value: Nullable$TYPE$): $TYPE$;
|
||||
begin
|
||||
Result := Value.Value;
|
||||
end;
|
||||
|
||||
class operator Nullable$TYPE$.Implicit(const Value: $TYPE$): Nullable$TYPE$;
|
||||
begin
|
||||
Result.Value := Value;
|
||||
end;
|
||||
|
||||
procedure Nullable$TYPE$.SetNull;
|
||||
begin
|
||||
fValue := Default ($TYPE$);
|
||||
fHasValue := '';
|
||||
end;
|
||||
|
||||
procedure Nullable$TYPE$.SetValue(const Value: $TYPE$);
|
||||
begin
|
||||
fValue := Value;
|
||||
fHasValue := '_';
|
||||
end;
|
||||
|
||||
function Nullable$TYPE$.ValueOrDefault: $TYPE$;
|
||||
begin
|
||||
if HasValue then
|
||||
begin
|
||||
Result := GetValue
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result := Default ($TYPE$);
|
||||
end;
|
||||
end;
|
||||
|
||||
///IMPLEMENTATION.END
|
||||
|
||||
end.
|
38
unittests/general/TestServer/TestServer.deployproj
Normal file
38
unittests/general/TestServer/TestServer.deployproj
Normal file
@ -0,0 +1,38 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Condition="Exists('$(BDS)\bin\CodeGear.Deployment.targets')" Project="$(BDS)\bin\CodeGear.Deployment.targets"/>
|
||||
<ProjectExtensions>
|
||||
<ProjectFileVersion>12</ProjectFileVersion>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup>
|
||||
<DeviceId Condition="'$(Platform)'=='Android'"/>
|
||||
<DeviceId Condition="'$(Platform)'=='Android64'"/>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition="'$(Platform)'=='Win64'"/>
|
||||
<ItemGroup Condition="'$(Platform)'=='Win32'"/>
|
||||
<ItemGroup Condition="'$(Platform)'=='Linux64'">
|
||||
<DeployFile Include="TestServer" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>TestServer\</RemoteDir>
|
||||
<RemoteName>TestServer</RemoteName>
|
||||
<DeployClass>ProjectOutput</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
<Required>True</Required>
|
||||
</DeployFile>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Platform)'=='OSX32'">
|
||||
<DeployFile Include="$(BDS)\Redist\osx32\libcgunwind.1.0.dylib">
|
||||
<RemoteDir>TestServer\</RemoteDir>
|
||||
<RemoteName>libcgunwind.1.0.dylib</RemoteName>
|
||||
<DeployClass>DependencyModule</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Platform)'=='Android'"/>
|
||||
<ItemGroup Condition="'$(Platform)'=='OSX64'"/>
|
||||
<ItemGroup Condition="'$(Platform)'=='Android64'"/>
|
||||
</Project>
|
BIN
unittests/general/TestServer/TestServer_Icon.ico
Normal file
BIN
unittests/general/TestServer/TestServer_Icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
1
unittests/general/TestServer/www/index.html
Normal file
1
unittests/general/TestServer/www/index.html
Normal file
@ -0,0 +1 @@
|
||||
This is a TEXT file
|
Loading…
Reference in New Issue
Block a user