<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    What I was a little bit more than hinting at in my previous answers
    is that it is impossible for an abstract read stream to know that
    there's a string to read. There is at least one higher level of
    implementation necessary: one that recognizes a string.<br>
    That means probably something like  storing the length and  storing
    a string marker and/or use RTTI for strings, to be consistent.<br>
    <br>
    In practice, I use json for that kind of streaming. And that is
    already in place.<br>
    <br>
    <div class="moz-cite-prefix">On 22-7-2014 14:37, Dmitry Boyarintsev
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAMpTZrca7HPavqhNx3UFWODObyx85NkDsJr=JHE-PB_J3hECGg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Tue, Jul 22, 2014 at 6:46 AM, <a
              moz-do-not-send="true" href="mailto:thaddy@thaddy.com">thaddy@thaddy.com</a>
            <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:thaddy@thaddy.com" target="_blank">thaddy@thaddy.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">A case for ternary
              computing is not really a bad idea ;)<br>
              <br>
              On 21-7-2014 21:42, Hans-Peter Diettrich wrote:<br>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px
                0.8ex;border-left:1px solid
                rgb(204,204,204);padding-left:1ex">
                Dmitry Boyarintsev schrieb:
                <div class=""><br>
                  <blockquote class="gmail_quote" style="margin:0px 0px
                    0px 0.8ex;border-left:1px solid
                    rgb(204,204,204);padding-left:1ex">
                    How about introducing a default parameter?<br>
                    The parameter keeps the method backward compatible,
                    allowing write a string without the prefix.<br>
                    <br>
                    public procedure TStream.WriteAnsiString(<br>
                      const S: string;<br>
                      withLength: Boolean = true;<br>
                  </blockquote>
                  <br>
                </div>
                How should a string without a length be read back?<br>
                <br>
                DoDi
                <div class=""><br>
                </div>
              </blockquote>
            </blockquote>
          </div>
          I didn't see DoDi's email anywhere in the thread, though it
          seems like there're two threads anyway:<br>
          "Re: [fpc-devel] Method for write string into TStream" and
          "[fpc-devel] Method for write string into TStream"<br>
        </div>
        <div class="gmail_extra"><br>
        </div>
        <div class="gmail_extra">Anyways, answering DoDi's question.<br>
        </div>
        <div class="gmail_extra">It definitely won't be able to read a
          string without a size, but it doesn't mean that the string
          size should immediately precede the string content. <br>
        </div>
        <div class="gmail_extra">So maybe a modification like this could
          help<br>
          <br>
          procedure TStream.ReadAnsiString(knownsize: Integer=-1)<br>
        </div>
        <div class="gmail_extra">   if knownsize<0 then <br>
        </div>
        <div class="gmail_extra">     TheSize := ...readsize <br>
        </div>
        <div class="gmail_extra">  else <br>
        </div>
        <div class="gmail_extra">     TheSize := knownsize<br>
        </div>
        <div class="gmail_extra"><br>
          thanks,<br>
          Dmitry<br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
fpc-devel maillist  -  <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>