Hello!<br /><br />Would you explain one moment. I need use a lot of STL collections in my Photoshop plug-in.<br /><br />First, I try to write something like<br />---------------------------------------------------------------------<br />#include <map><br />#include <string><br /><br />...<br /><br /> map<int,string> foo; // BANG!<br />---------------------------------------------------------------------<br /><br />Next, I try to use Photoshop Basic Suite:<br /><br />---------------------------------------------------------------------<br />#include <algorithm><br /><br />namespace std {}<br />using namespace std;<br /><br />#include <PIFormat.h><br /><br />extern SPBasicSuite *g_sSPBasic;<br /><br />inline void * operator new ( const size_t size )<br />{<br /> void *result = 0;<br /><br /> if( 0 != g_sSPBasic )<br /> {<br /> void *temp;<br /><br /> if( g_sSPBasic->AllocateBlock( size, &result ) )<br /> {<br /> result = 0;<br /> }<br /> else<br /> {<br />#ifdef DEBUG<br /> char *tmp = static_cast<char*>( result );<br /> fill( tmp, tmp + size, 0xEB );<br />#endif<br /> }<br /> }<br /><br /> return result;<br />}<br /><br />inline void operator delete ( void * ptr )<br />{<br /> if( 0 != g_sSPBasic )<br /> {<br /> g_sSPBasic->FreeBlock( ptr );<br /> }<br />}<br /><br />// the same for operator new[] and operator delete[]<br />---------------------------------------------------------------------<br /><br />Now simple STL collections can be created.<br /><br />Is there more laconic way to create STL collections?<br /><br />Moreover. This code is very dirty. For example, I even don't sure that Simple Suite address is constant between calls of plug-in entry point. So I think this is an awful dangerous code (just imagine the effect of two copies of of Adobe Photoshop using plug-in using this operators simultaneously).<br /><br />Do you have some ideas how to make it clean and working?
↧