Hi Sven, rawData is not just a list of bytes. In this structure all static content from the component is collected. If you have something like "<p><$ a+b $></p>" the generated code must output first "<p>" then result of the expression "a+b" and then "</p>". The ecppc collects all static stuff into one array. In this array the first 4 bytes points to the first data chunk. "<p>" in our example. The second 4 bytes points to the second and so on. So the code can access the n-th chunk easily just by reading the pointer to the chunk and the pointer to the next chunk. The last length field points to the end of the field.
In case of binary mode (ecppc -b) there is actually just one chunk. So the first 4 bytes points to the data to the beginning of the data and the next 4 bytes to the end. You can see, that the first 4 bytes in your example is \010\000\000\000. "\010" is the octal representation of decimal 8. So the png starts at the 8-th byte, where you can find the "PNG". The next 4 bytes point to the end of the png and hence the value should be the size of the png + 8 bytes. Originally I implemented it to make this static content loadable from a external source. The aim was to realize internationalization with that. The code is there but maintaining this separate content with a different language became a nightmare in the project and hence I do not recommend its use. But as a size effect it gave me a chance for another feature, which is useful. Using "ecppc -z" the rawData is compressed and hence reduces the size of the binary for components with much static content. The data is then decompressed on first access. Tommi Am 22.01.2014 10:25, schrieb Sven Bergmann: > Hi Tommi, > > Thanks for this post, your side note was the information, I was > searching for now 2 days. > > I'm also new on tntnet and I really like it. > > On my search for a C++ web development toolkit, tntnet works best for > me, because I like the template style more than Qt GUI style from witty. > > What I worked on the last days is a FileCache class, which loads and > stores files if required. It worked well with text files, but not with > image files. After removing all empty lines between the tags, it is > working as expected. > > Another question is for me, what is the reason, if you are generating > with "ecppc -b -m image/png -o b.cpp b.png" that the const char* rawData > > static const char* rawData = > "\010\000\000\000KO\005\000\211PNG\015\n\032\n\000\000\000\015IHDR\000\000..... > > starts with "\010\000\000\000KO\005\000" and not with the first bytes of > the file "\211PNG\015\n\032\n...."? > > I was not able to identify where it comes from and what it is? > > Hope you can bring in some light in the tunnel and thanks again for > sharing this nice project with the rest of the world. > > Best regards, > Sven > > On 29.12.2013 12:49, Tommi Mäkitalo wrote: >> Am 29.12.2013 10:06, schrieb Olaf Radicke: >>> Hi Carsten, >>> >> ... >>> ...on this site: >>> http://www.tntnet.org/howto/static-howto.html >>> >>> >>> greetings, >>> >>> Olaf >>> (munich, germany) >> Hi, >> >> yes, the static howto is a good place to start. >> >> To recap, what you need: >> >> reply.setContentType(std::string) >> >> sets the content type. The method >> >> reply.out() >> >> returns a reference to a std::ostream, where you write your data into. >> So the shortest possible code is here: >> >> <%cpp> >> reply.setContentType("image/jpeg"); >> reply.out() << generateImageData(); >> </%cpp> >> >> As a alternative you have a class, which generates the image data in the >> output operator for std::ostream. But I'm sure that you know how to do that. >> >> One side note: you have to be careful with empty lines. You have to make >> sure, your ecpp do not contain any empty lines outside the <%cpp> >> section since it is written to the output stream and may corrupt your >> image. But as a special feature of ecpp one line feed after the end tag >> </%cpp> is not sent to the output stream. >> >> Tommi >> >> >> >> ------------------------------------------------------------------------------ >> Rapidly troubleshoot problems before they affect your business. Most IT >> organizations don't have a clear picture of how application performance >> affects their revenue. With AppDynamics, you get 100% visibility into your >> Java,.NET,& PHP application. Start your 15-day FREE TRIAL of AppDynamics >> Pro! >> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk >> >> >> >> _______________________________________________ >> Tntnet-general mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/tntnet-general > > > ------------------------------------------------------------------------------ > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. > http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk > _______________________________________________ > Tntnet-general mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/tntnet-general ------------------------------------------------------------------------------ CenturyLink Cloud: The Leader in Enterprise Cloud Services. Learn Why More Businesses Are Choosing CenturyLink Cloud For Critical Workloads, Development Environments & Everything In Between. Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk _______________________________________________ Tntnet-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tntnet-general
