<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EntwicklerForum.org &#187; Delphi</title>
	<atom:link href="http://www.entwicklerforum.org/tag/delphi/feed" rel="self" type="application/rss+xml" />
	<link>http://www.entwicklerforum.org</link>
	<description>Tipps und Tricks für Entwickler</description>
	<lastBuildDate>Fri, 09 Dec 2011 17:54:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Delphi Applikationen mit Laufzeit-Bibliotheken</title>
		<link>http://www.entwicklerforum.org/delphi-applikationen-mit-laufzeit-bibliotheken</link>
		<comments>http://www.entwicklerforum.org/delphi-applikationen-mit-laufzeit-bibliotheken#comments</comments>
		<pubDate>Tue, 29 Jul 2008 12:29:01 +0000</pubDate>
		<dc:creator>Martin Schmid</dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://www.entwicklerforum.org/?p=127</guid>
		<description><![CDATA[Bei Delphi gibt es die M&#246;glichkeit Programm mit Laufzeitbibliotheken (BPL) zu ver&#246;ffentlichen. Dies lohnt sich, dann wenn man mehre Applikationen hat, die dieselben Komponenten verwenden, da die Anwendung dann viel kleiner wird. Wichtig ist dabei, dann man nicht nur die Dateien mit der Endung .bpl sondern auch die Sprachdatei mit der Endung .de zur Applikation [...]]]></description>
			<content:encoded><![CDATA[<p>Bei Delphi gibt es die M&#246;glichkeit Programm mit Laufzeitbibliotheken (BPL) zu ver&#246;ffentlichen.</p>
<p>Dies lohnt sich, dann wenn man mehre Applikationen hat, die dieselben Komponenten verwenden,<br />
da die Anwendung dann viel kleiner wird.</p>
<p><span id="more-127"></span>Wichtig ist dabei, dann man nicht nur die Dateien mit der Endung .bpl sondern auch die Sprachdatei mit der Endung .de zur Applikation packt, sondern kann es passieren, dass z.B. Standard Dialoge beim Button &#8220;Ja&#8221; pl&#246;tzlich &#8220;Yes&#8221; schreiben.</p>
<p>Bei Packages von Fremdherstellern kann das allerdings schwierig werden <img src='http://www.entwicklerforum.org/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>Wenn man wissen m&#246;chte, welche Dateien von einer Applikation verwendet werden, kann man das Tool Dependency Walker verwenden.</p>
<p><a title="Dependency Walker" href="http://dependencywalker.com/" target="_blank">http://dependencywalker.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.entwicklerforum.org/delphi-applikationen-mit-laufzeit-bibliotheken/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Priorit&#228;t des Hauptprozesses &#228;ndern</title>
		<link>http://www.entwicklerforum.org/prioritaet-des-hauptprozesses-aendern</link>
		<comments>http://www.entwicklerforum.org/prioritaet-des-hauptprozesses-aendern#comments</comments>
		<pubDate>Tue, 08 Jul 2008 14:24:52 +0000</pubDate>
		<dc:creator>Pascal Potrafke</dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://www.entwicklerforum.org/?p=100</guid>
		<description><![CDATA[Ab und an ist es n&#246;tig die Prozesspriorit&#228;t der eigenen Anwendung zu &#228;ndern. var hdlMyApp : THandle; &#160; hdlMyApp := GetCurrentThread; SetThreadPriority&#40; hdlMyApp , THREAD_PRIORITY_IDLE &#41;;]]></description>
			<content:encoded><![CDATA[<p>Ab und an ist es n&#246;tig die Prozesspriorit&#228;t der eigenen Anwendung zu &#228;ndern.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span>
  hdlMyApp <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">THandle</span><span style="color: #000066;">;</span>
&nbsp;
  hdlMyApp <span style="color: #000066;">:</span><span style="color: #000066;">=</span> GetCurrentThread<span style="color: #000066;">;</span>
  SetThreadPriority<span style="color: #000066;">&#40;</span> hdlMyApp <span style="color: #000066;">,</span> THREAD_PRIORITY_IDLE <span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.entwicklerforum.org/prioritaet-des-hauptprozesses-aendern/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objekte serealisieren und deserialisieren</title>
		<link>http://www.entwicklerforum.org/objekte-serealisieren-und-deserialisieren</link>
		<comments>http://www.entwicklerforum.org/objekte-serealisieren-und-deserialisieren#comments</comments>
		<pubDate>Sun, 22 Jun 2008 10:05:41 +0000</pubDate>
		<dc:creator>Pascal Potrafke</dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://www.entwicklerforum.org/?p=98</guid>
		<description><![CDATA[Sch&#246;nen guten Tag liebe Delphi Gemeinde! Was in vielen &#8220;modernen&#8221; Sprachen bereits gang und g&#228;be ist und zum guten Ton geh&#246;rt haben wir nicht zur Verf&#252;gung, das serealisieren und deserialisieren von Objekten. Mit hilfe der RTTI (Run Time Type Info) und einigen Einschr&#228;nkungen gibt es jedoch auch f&#252;r uns die M&#246;glichkeit derartige Mechanismen zu schaffen. [...]]]></description>
			<content:encoded><![CDATA[<p>Sch&#246;nen guten Tag liebe Delphi Gemeinde!<br />
 Was in vielen &#8220;modernen&#8221; Sprachen bereits gang und g&#228;be ist und zum guten Ton geh&#246;rt haben wir nicht zur Verf&#252;gung, das serealisieren und deserialisieren von Objekten. Mit hilfe der RTTI (Run Time Type Info) und einigen Einschr&#228;nkungen gibt es jedoch auch f&#252;r uns die M&#246;glichkeit derartige Mechanismen zu schaffen. Im folgendem m&#246;chte ich gerne meinen L&#246;sungsansatz vorstellen, der mir und vielleicht sogar dem ein oder anderem Arbeit erspart oder zumindest Hilfestellung gibt.<br />
 <span id="more-98"></span><br />
 Da ich in der Entwicklung alle meine Objekte mit dieser Funktion ausstatten m&#246;chte, muss ich mir eine eigene Classroot schaffen. Ich habe mich an dieser Stelle f&#252;r den Typ TPersistent als Vaterklasse entschieden, da mir dieser die Methode Assign() zur Verf&#252;gung stellt.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">type</span>
  TeqObject <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span> TPersistent <span style="color: #000066;">&#41;</span></pre></div></div>

<p>In meiner eigenen Entwicklung leite ich nun alle meine ben&#246;tigten Klassen von TeqObject ab.<br />
 Ein einfaches Beispiel soll die Anwendung und den Nutzen demonstrieren.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">type</span> TMitarbeiter <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span> TeqObject <span style="color: #000066;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">private</span>
    M_Vorname <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span><span style="color: #000066;">;</span>
    M_Nachname <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span><span style="color: #000066;">;</span>
    M_Alter <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">published</span>
    <span style="color: #000000; font-weight: bold;">property</span> Vorname <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span> <span style="color: #000066;">read</span> M_Vorname <span style="color: #000066;">write</span> M_Vorname<span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">property</span> Nachname <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span> <span style="color: #000066;">read</span> M_Nachname <span style="color: #000066;">write</span> M_Nachname<span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">property</span> Alter <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span> <span style="color: #000066;">read</span> M_Alter <span style="color: #000066;">write</span> M_Alter<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> ErzeugeMitarbeiter<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span>
  mitarbeiter <span style="color: #000066;">:</span> TMitarbeiter<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  mitarbeiter <span style="color: #000066;">:</span><span style="color: #000066;">=</span> TMitarbeiter<span style="color: #000066;">.</span><span style="color: #006600;">Create</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">with</span> mitarbeiter <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #000000; font-weight: bold;">begin</span>
    Vorname  <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'Pascal'</span><span style="color: #000066;">;</span>
    Nachname <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'Potrafke'</span><span style="color: #000066;">;</span>
    Alter    <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">24</span><span style="color: #000066;">;</span>
    SaveAsXML<span style="color: #000066;">&#40;</span> <span style="color: #ff0000;">'mitarbeiter.xml'</span> <span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
  <span style="color: #000066;">FreeAndNil</span><span style="color: #000066;">&#40;</span> mitarbeiter <span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p>Was habe ich nun gemacht? Ich habe ein Klasse erstellt, von dieser ein Objekt instanziiert und dieses einfach als XML gespeichert. Das ergebnis sieht wie folgt aus.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  24
  Potrafke
  Pascal</pre></div></div>

<p>Die Delphi RTTI erlaubt es nur auf Eigenschaften zuzugreifen die im published Block definiert sind. Es werden also nicht alle Member Eigenschaften serialisiert. Das ist auch der Grund daf&#252;r, dass in dem Beispiel nur die Properties in der XML Datei zu sehen sind.<br />
 Was serialisiert wurde kann nat&#252;rlich auch wieder deserialisiert werden. Daf&#252;r gibt es das obligatorische Gegenst&#252;ck zur allen Save() Methoden in Delphi, n&#228;mlich die Load() Methoden.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">mitarbeiter<span style="color: #000066;">.</span><span style="color: #006600;">LoadFromXML</span><span style="color: #000066;">&#40;</span> <span style="color: #ff0000;">'mitarbeiter.xml'</span> <span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>Soweit so gut, allerdings gibt es auch die ein oder andere Einschr&#228;nkung. Im Detail bedeutet das, dass nicht f&#252;r alle Typen von Borland RTTI Informationen zur Laufzeit erzeugt werden.<br />
 Dazu geh&#246;ren tkRecord, tkArray, tkDynArray (bedingt) und Pointer jeglicher Art.</p>
<ol>tkArray: Delphi brauch hier keine Informationen, da normale (statische) Arrays kein Cleanup brauchen. </ol>
<ol>tkDynArray: F&#252;r tkDynArray wird zwar eine RTTI Information zur Laufzeit erzeugt, diese dient Delphi jedoch nur um bei dem Speicher Management die Infos zu bekommen wieviele Eintr&#228;ge es von welchem Typ aufr&#228;umen muss. </ol>
<p>Ein kurzer Ausschnitt aus der TypeInfo.pas (Delphi 2007 Version 11) soll die fehlenden Implementationen zeigen.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;">  TTypeData <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">packed</span> <span style="color: #000000; font-weight: bold;">record</span>
    <span style="color: #000000; font-weight: bold;">case</span> TTypeKind <span style="color: #000000; font-weight: bold;">of</span>
      tkUnknown<span style="color: #000066;">,</span> tkLString<span style="color: #000066;">,</span> tkWString<span style="color: #000066;">,</span> tkVariant<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      tkInteger<span style="color: #000066;">,</span> tkChar<span style="color: #000066;">,</span> tkEnumeration<span style="color: #000066;">,</span> tkSet<span style="color: #000066;">,</span> tkWChar<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span>
        OrdType<span style="color: #000066;">:</span> TOrdType<span style="color: #000066;">;</span>
        <span style="color: #000000; font-weight: bold;">case</span> TTypeKind <span style="color: #000000; font-weight: bold;">of</span>
          tkInteger<span style="color: #000066;">,</span> tkChar<span style="color: #000066;">,</span> tkEnumeration<span style="color: #000066;">,</span> tkWChar<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span>
            <span style="color: #000066;">MinValue</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Longint</span><span style="color: #000066;">;</span>
            <span style="color: #000066;">MaxValue</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Longint</span><span style="color: #000066;">;</span>
            <span style="color: #000000; font-weight: bold;">case</span> TTypeKind <span style="color: #000000; font-weight: bold;">of</span>
              tkInteger<span style="color: #000066;">,</span> tkChar<span style="color: #000066;">,</span> tkWChar<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
              tkEnumeration<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span>
                BaseType<span style="color: #000066;">:</span> PPTypeInfo<span style="color: #000066;">;</span>
                NameList<span style="color: #000066;">:</span> ShortStringBase<span style="color: #000066;">;</span>
                EnumUnitName<span style="color: #000066;">:</span> ShortStringBase<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
          tkSet<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span>
            CompType<span style="color: #000066;">:</span> PPTypeInfo<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      tkFloat<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span>
        FloatType<span style="color: #000066;">:</span> TFloatType<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      tkString<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span>
        MaxLength<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Byte</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      tkClass<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span>
        ClassType<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TClass</span><span style="color: #000066;">;</span>
        ParentInfo<span style="color: #000066;">:</span> PPTypeInfo<span style="color: #000066;">;</span>
        PropCount<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">SmallInt</span><span style="color: #000066;">;</span>
        UnitName<span style="color: #000066;">:</span> ShortStringBase<span style="color: #000066;">;</span>
       <span style="color: #808080; font-style: italic;">{PropData: TPropData}</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      tkMethod<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span>
        MethodKind<span style="color: #000066;">:</span> TMethodKind<span style="color: #000066;">;</span>
        <span style="color: #000066;">ParamCount</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Byte</span><span style="color: #000066;">;</span>
        ParamList<span style="color: #000066;">:</span> <span style="color: #000000; font-weight: bold;">array</span><span style="color: #000066;">&#91;</span><span style="color: #0000ff;">0</span><span style="color: #000066;">..</span><span style="color: #0000ff;">1023</span><span style="color: #000066;">&#93;</span> <span style="color: #000000; font-weight: bold;">of</span> <span style="color: #000066; font-weight: bold;">Char</span>
       <span style="color: #808080; font-style: italic;">{ParamList: array[1..ParamCount] of
          record
            Flags: TParamFlags;
            ParamName: ShortString;
            TypeName: ShortString;
          end;
        ResultType: ShortString}</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      tkInterface<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span>
        IntfParent <span style="color: #000066;">:</span> PPTypeInfo<span style="color: #000066;">;</span> <span style="color: #808080; font-style: italic;">{ ancestor }</span>
        IntfFlags <span style="color: #000066;">:</span> TIntfFlagsBase<span style="color: #000066;">;</span>
        Guid <span style="color: #000066;">:</span> TGUID<span style="color: #000066;">;</span>
        IntfUnit <span style="color: #000066;">:</span> ShortStringBase<span style="color: #000066;">;</span>
       <span style="color: #808080; font-style: italic;">{PropData: TPropData}</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      tkInt64<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span>
        MinInt64Value<span style="color: #000066;">,</span> MaxInt64Value<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Int64</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
      tkDynArray<span style="color: #000066;">:</span> <span style="color: #000066;">&#40;</span>
        elSize<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Longint</span><span style="color: #000066;">;</span>
        elType<span style="color: #000066;">:</span> PPTypeInfo<span style="color: #000066;">;</span>       <span style="color: #808080; font-style: italic;">// nil if type does not require cleanup</span>
        varType<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span>         <span style="color: #808080; font-style: italic;">// Ole Automation varType equivalent</span>
        elType2<span style="color: #000066;">:</span> PPTypeInfo<span style="color: #000066;">;</span>      <span style="color: #808080; font-style: italic;">// independent of cleanup</span>
        DynUnitName<span style="color: #000066;">:</span> ShortStringBase<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p>Das hat zur Folge, das wenn man dieses Feature verwenden m&#246;chte, sich von Records und (dynamischen) Arrays verabschieden muss.<br />
 Anstelle von Records werden nun Klassen verwendet. Was bereits beim Mitarbeiter Beispiel gemacht wurde. Denn f&#252;r solch einfache Strukturen h&#228;tte es eigentlich auch ein normaler Record getan.<br />
 Dennoch denke ich das dieser geringe Mehraufwand bei der Definition in hinsicht auf das (de)serialisieren kaum ins Gewicht f&#228;llt.<br />
 (Dynamische) Arrays werden nun durch eine weitere Classroot ersetzt.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">type</span> TDyneqObjectList <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">array</span> <span style="color: #000000; font-weight: bold;">of</span> TeqObject<span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TeqObjectList <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span> TeqObject <span style="color: #000066;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">private</span>
    M_List <span style="color: #000066;">:</span> TDyneqObjectList<span style="color: #000066;">;</span>
<span style="color: #000066;">...</span>
<span style="color: #000066;">...</span>
<span style="color: #000066;">...</span></pre></div></div>

<p>Mit dieser Listenklassen k&#246;nnen Array Strukturen abgebildet werden und das (de)serialisieren Feature weiterhin bequem verwendet werden. Folgendes Beispiel soll die Listenklasse demonstrieren.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">type</span> TUnternehmen <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span> TeqObject <span style="color: #000066;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">private</span>
    M_Firmenname <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span><span style="color: #000066;">;</span>
    M_Internetadresse <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span><span style="color: #000066;">;</span>
    M_Mitarbeiter <span style="color: #000066;">:</span> TeqObjectList<span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span>
    <span style="color: #000000; font-weight: bold;">constructor</span> Create<span style="color: #000066;">;</span> <span style="color: #000000; font-weight: bold;">override</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">published</span>
    <span style="color: #000000; font-weight: bold;">property</span> Firmenname <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span> <span style="color: #000066;">read</span> M_Firmenname <span style="color: #000066;">write</span> M_Firmenname<span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">property</span> Internetadresse <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span> <span style="color: #000066;">read</span> M_Internetadresse <span style="color: #000066;">write</span> M_Internetadresse<span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">property</span> Mitarbeiter <span style="color: #000066;">:</span> TeqObjectList <span style="color: #000066;">read</span> M_Mitarbeiter <span style="color: #000066;">write</span> M_Mitarbeiter<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span> TMitarbeiter <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span> TeqObject <span style="color: #000066;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">private</span>
    M_Vorname <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span><span style="color: #000066;">;</span>
    M_Nachname <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span><span style="color: #000066;">;</span>
    M_Alter <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">published</span>
    <span style="color: #000000; font-weight: bold;">property</span> Vorname <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span> <span style="color: #000066;">read</span> M_Vorname <span style="color: #000066;">write</span> M_Vorname<span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">property</span> Nachname <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">String</span> <span style="color: #000066;">read</span> M_Nachname <span style="color: #000066;">write</span> M_Nachname<span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">property</span> Alter <span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span> <span style="color: #000066;">read</span> M_Alter <span style="color: #000066;">write</span> M_Alter<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">constructor</span> TUnternehmen<span style="color: #000066;">.</span><span style="color: #006600;">Create</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000000; font-weight: bold;">inherited</span> Create<span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">Self</span><span style="color: #000066;">.</span><span style="color: #006600;">M_Mitarbeiter</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> TeqObjectList<span style="color: #000066;">.</span><span style="color: #006600;">Create</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">procedure</span> ErzeugeUnternehmen<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span>
  unternehmen <span style="color: #000066;">:</span> TUnternehmen<span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  unternehmen <span style="color: #000066;">:</span><span style="color: #000066;">=</span> TUnternehmen<span style="color: #000066;">.</span><span style="color: #006600;">Create</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">with</span> unternehmen <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #000000; font-weight: bold;">begin</span>
    Firmenname      <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'EQUITANIA Software GmbH'</span><span style="color: #000066;">;</span>
    Internetadresse <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'http://www.equitania.de'</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">with</span> <span style="color: #000066;">&#40;</span> Mitarbeiter<span style="color: #000066;">.</span><span style="color: #006600;">Item</span><span style="color: #000066;">&#91;</span> Mitarbeiter<span style="color: #000066;">.</span><span style="color: #006600;">Add</span><span style="color: #000066;">&#40;</span> TMitarbeiter<span style="color: #000066;">.</span><span style="color: #006600;">Create</span> <span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#93;</span> <span style="color: #000000; font-weight: bold;">as</span> TMitarbeiter <span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #000000; font-weight: bold;">begin</span>
      Vorname  <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'Pascal'</span><span style="color: #000066;">;</span>
      Nachname <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'Potrafke'</span><span style="color: #000066;">;</span>
      Alter    <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">24</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">with</span> <span style="color: #000066;">&#40;</span> Mitarbeiter<span style="color: #000066;">.</span><span style="color: #006600;">Item</span><span style="color: #000066;">&#91;</span> Mitarbeiter<span style="color: #000066;">.</span><span style="color: #006600;">Add</span><span style="color: #000066;">&#40;</span> TMitarbeiter<span style="color: #000066;">.</span><span style="color: #006600;">Create</span> <span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#93;</span> <span style="color: #000000; font-weight: bold;">as</span> TMitarbeiter <span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #000000; font-weight: bold;">begin</span>
      Vorname  <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'Paul'</span><span style="color: #000066;">;</span>
      Nachname <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'Exler'</span><span style="color: #000066;">;</span>
      Alter    <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">24</span><span style="color: #000066;">;</span>
    <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
    SaveAsXML<span style="color: #000066;">&#40;</span> <span style="color: #ff0000;">'unternehmen.xml'</span> <span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p>Die List funktioniert wie eine StringList und besitzt Methode wie Add(), Remove(), Item, etc.<br />
 Das Ergebnis sieht nun wie folgt aus.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  EQUITANIA Software GmbH
  http://www.equitania.de
&nbsp;
      24
      Potrafke
      Pascal
&nbsp;
      24
      Exler
      Paul</pre></div></div>

<p>Von der Komplexit&#228;t der Klassenstrukturen gibt es keinerlei Einschr&#228;nkungen.<br />
 Auch das Einlesen dieses XML Gebildes ist kein Problem. Einzige Schwierigkeit war hier, das beim einlesen die Objekte IN der Liste von dem jeweiligen Typ instanziiert werden m&#252;ssen damit zur Laufzeit drauf zur&#252;ckgegriffen werden kann. Aber auch darum muss man sich nicht mehr k&#252;mmern.<br />
 Was man jedoch derzeit noch von Hand machen musst ist das registrieren der Klassen. Ohne dem werden bzw. k&#246;nnen die Objekte nicht instanziiert werden.</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">initialization</span>
  <span style="color: #000066;">RegisterClasses</span><span style="color: #000066;">&#40;</span> <span style="color: #000066;">&#91;</span> TUnternehmen<span style="color: #000066;">,</span> TMitarbeiter <span style="color: #000066;">&#93;</span> <span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></pre></div></div>

<p>So, nun w&#252;nsche ich viel Spass beim ausprobieren.<br />
 Eines m&#246;chte ich noch sagen. Der Code kann Fehler enthalten. Daher ist die Benutzung auf eigene Gefahr. Verbesserungsvorschl&#228;ge und Anregungen gerne gesehen.<br />
 <a href="http://www.entwicklerforum.org/wp-content/uploads/2008/06/core.zip">Sourcecode zum Download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.entwicklerforum.org/objekte-serealisieren-und-deserialisieren/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi online Handbuch</title>
		<link>http://www.entwicklerforum.org/delphi-online-handbuch</link>
		<comments>http://www.entwicklerforum.org/delphi-online-handbuch#comments</comments>
		<pubDate>Thu, 20 Sep 2007 09:46:45 +0000</pubDate>
		<dc:creator>Martin Schmid</dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://www.entwicklerforum.org/?p=73</guid>
		<description><![CDATA[Ein recht gelungenes Delphi/ObjectPascal Handbuch findet man online unter unter http://de.wikibooks.org/wiki/Delphi Weitere B&#252;cher zu IT Themen findet man ebenfalls unter http://de.wikibooks.org/wiki/Regal:Programmierung]]></description>
			<content:encoded><![CDATA[<p>Ein recht gelungenes Delphi/ObjectPascal Handbuch  findet man online unter unter <a title="Delphi Handbuch" href="http://de.wikibooks.org/wiki/Delphi" target="_blank">http://de.wikibooks.org/wiki/Delphi</a></p>
<p>Weitere B&#252;cher zu IT Themen findet man ebenfalls unter <a title="Wikibooks" href="http://de.wikibooks.org/wiki/Regal:Programmierung" target="_blank">http://de.wikibooks.org/wiki/Regal:Programmierung </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.entwicklerforum.org/delphi-online-handbuch/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

