Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 01/20/20 in all areas

  1. Stefan Glienke

    Null value for T

    Sure, write your own compiler
  2. Remy Lebeau

    Null value for T

    Default() is a compiler intrinsic function, it is built right in to the compiler itself. That being said, I would suggest some tweaks to your code. There is no need to search for the key twice, that is just wasted overhead. Use the TryGetValue() method instead, which searches the key once and returns its value if found: Function TMyClass<T>.Get(Identifier: String): T; Begin If not list.TryGetValue(Identifier, Result) Then Result := Default(T); End; Alternatively, TryGetValue() sets the output value to Default(T) for you if the key is not found, so you don't need to do it explicitly at all: Function TMyClass<T>.Get(Identifier: String): T; Begin list.TryGetValue(Identifier, Result); End; But either way, this approach does not allow the caller to differentiate between a key that is actually missing vs a key that happens to have the same value as its default. So I would suggest returning a Boolean instead to tell the caller whether the key was found or not: TMyClass<T> = Class strict protected list: TDictionary<String, T>; public Function Get(Identifier: String, out Value: T): Boolean; End; Function TMyClass<T>.Get(Identifier: String; out Value: T) Boolean; Begin Result := list.TryGetValue(Identifier, Value); End;
  3. David Heffernan

    Open jpg Image as Text File

    Just upload the image to some file sharing site. And show your code to process the EXIF.
  4. Dave Craggs

    Delphi in the UK

    Yes - I have done a lot of C#, but self taught, so bit of a harder sell.
  5. Angus Robertson

    Only default ICS sample SSL certificate is working

    Sorry, seems the CreateSelfSignedCert function in OverbyteIcsSslX509Utils.pas got broken while being modernised, you need to add a missing line: MySslCertTools.ExpireDays := Days; { V8.64 got lost } and it will work properly again. Sorry, did not test that old function properly. The modern way to create a self signed certificate is using fields and buttons on the New Certificate Properties and Create Certificates tabs. First click 'Generate Key Pair', complete the various New Certificate Request Properties, previous tab, click 'Create Self Signed Cert from Properties', then at the bottom of the tab specify the file names for the formats you want to save, tick if you want the private key in the same file, then click the buttons to save in PEM, PKCS12, DER, etc. Finally on the List Certificate tab, click View Single File to double check the certificate is created properly. Those three tabs perform most of the common certificate functions of the OpenSSL command line tool. Angus
  6. Dalija Prasnikar

    Null value for T

    Yes, there is. Result :=Default(T);
  7. Remy Lebeau

    Memory leak in UnicodeString to string conversion

    Then you are going to have to ask the library author to change it, because this implementation is broken. IRecognitionResult is derived from IDispatch, which is an OLE interface. Pascal strings simply are not compatible with OLE - period. The Pascal wrapper for the interface MUST use WideString instead, which uses the OLE BSTR string type.
  8. Remy Lebeau

    Memory leak in UnicodeString to string conversion

    That type-cast is not necessary. Assigning a String (or a WideString) to a String is handled automatically by the compiler. This is not the source of your leaking. Did you change the recognition_text property to return a WideString instead of a String, like I suggested 8 months ago? What does the implementation of Get_text() actually look like?
×