Download Now

    Reference TTextStorage

    Declared in Codebot.Text.Store.pas on line 67

    TTextStorage stores text at design time. Data holds a single block of text which can be treated as json or xml. Items holds any number of named blocks of text which can be read or written by name using Values.
      TTextStorage = class(TComponent)
      protected
        procedure Loaded; override;
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
        { Load Data from a file named after the component in the application config
          directory }
        procedure LoadAppConfig;
        { Commit and save Data to a file named after the component in the
          application config directory }
        procedure SaveAppConfig;
        { Write changes made through AsJson or AsXml back into Data }
        procedure Commit;
        { Discard changes made through AsJson or AsXml so they are reparsed from
          Data }
        procedure Restore;
        { Parse Data as json, setting DataFormat to dfJson }
        function AsJson: TJsonNode;
        { Parse Data as xml, setting DataFormat to dfXml }
        function AsXml: IDocument;
        { Values reads the text of a named item, raising an exception if there is no
          item with that name. Writing adds the item if it does not exist. }
        property Values[Name: string]: string read GetValue write SetValue; default;
      published
        { Data holds a single block of text treated as json or xml }
        property Data: TStrings read FData write SetData;
        { Items holds named blocks of text }
        property Items: TTextItems read FItems write SetItems;
        { The format of Data }
        property DataFormat: TDataTextFormat read FDataFormat write SetDataFormat;
        { When true Data is loaded from the application config directory at runtime }
        property UseAppConfig: Boolean read FUseAppConfig write FUseAppConfig;
      end;

    See also

    IDocument in Codebot.Text.Xml.pas
    TJsonNode in Codebot.Text.Json.pas