{"id":171237,"date":"2013-03-03T15:05:03","date_gmt":"2013-03-03T11:05:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=171237"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=171237","title":{"rendered":"<span class=\"post_title\">\u0412\u043e\u0437\u0440\u043e\u0436\u0434\u0435\u043d\u0438\u0435 Framework-\u0430 (\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430)<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 <a href=\"https:\/\/github.com\/GlukKazan\/mf2\">Marmalade Framework<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0435\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b <a href=\"http:\/\/habrahabr.ru\/post\/170255\/\">\u0440\u0430\u043d\u0435\u0435<\/a>. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u0448\u0430\u0433\u0435, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 (templates), \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0448\u0435\u0439 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0441\u0442\u0430\u043d\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">main.json<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>{ load:         state.json,   display:    { width:                720,                 orientation:          portrait               },   templates: { wt_N:   { action:      w_N,                          name:        wr_N,                          template:    lock,                          x:           1,                          template:    y,                          width:      -1,                          height:      30,                          image:       w_N                        },                worlds: { regions: [ { templates: { y:    { y:    1 } },                                       template:            wt_1                                     },                                     { templates: { y:    { y:    31 } },                                       templates: { lock: { lock: stars&gt;=10 } },                                       template:            wt_1                                     }                                   ]                        }              },   scopes:    { start:        { default:          Y,                                vars:           { type:            number,                                                  stars:           0                                                },                                vars:           { background:      world_frame,                                                  back:            quit                                                },                                regions:      [ { zorder:         -1,                                                  x:               10,                                                  y:               10,                                                  width:          -10,                                                  height:         -10,                                                  template:        worlds                                                }                                              ]                              },                 w_N:         { load:             w_N.json,                                game:             arcanoid,                                vars:           { type:            number,                                                  life:            5,                                                  score:           0                                                },                                vars:           { background:      b_N,                                                  back:            back                                                },                                set:            { event:           impact,                                                  score:           score+10                                                }                              }               } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435, \u0447\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043d\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 (\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0435\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u044d\u0442\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430).<\/p>\n<p>  \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/f06\/326\/f2d\/f06326f2dc5ca670a405c3cf43f7ffe5.png\"\/><\/p>\n<p>  \u0412\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430\u043c\u0438 AbstractLoader. \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 ScopeDef (\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439), \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 RegionDef (\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u044d\u043a\u0440\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439) \u0438 VarDef (\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445). RegionDef \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 RegionDef \u0438 VarDef. Template \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435, \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0435\u0439 \u0443 \u043c\u0435\u043d\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u043e\u043a. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u044f \u0447\u0442\u043e-\u0442\u043e \u0434\u0435\u043b\u0430\u043b (\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u0434\u0435\u043b\u0430\u0442\u044c) \u043d\u0435 \u0442\u0430\u043a, \u043d\u043e std::string \u0440\u0430\u0437\u0440\u0443\u0448\u0430\u044e\u0442 \u043c\u043d\u0435 \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044f \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0441 \u044d\u0442\u0438\u043c \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f, \u043d\u043e \u043f\u043e\u0442\u043e\u043c \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0441\u0432\u043e\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a, \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u043e\u043f\u0440\u043e\u0441 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0441\u0442\u043e\u0438\u0442 \u043e\u0441\u0442\u0440\u043e, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0443\u043b\u0430 \u0441\u0442\u0440\u043e\u043a:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">StringPool.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _STRING_POOL_H_ #define _STRING_POOL_H_  #include &lt;stdio.h&gt; #include &lt;string.h&gt; #include &lt;map&gt;  using namespace std;  namespace mf2 {  class StringPool { \tprivate: \t\tstruct Value { \t\t\tValue(const char* s): strValue(s) {} \t\t\tValue(const Value& p): strValue(p.strValue) {} \t\t\tbool operator&lt;(const Value& p) const  {return strcmp(strValue, p.strValue) &lt; 0;} \t\t\tconst char* strValue; \t\t}; \t\tmap&lt;Value, int&gt;* usage; \tpublic: \t\tvoid init(); \t\tvoid release();  \t\tbool freeString(const char* s); \t\tconst char* getString(const char* s); \t\tconst char* getString(char c);  \ttypedef map&lt;Value, int&gt;::iterator VIter; \ttypedef pair&lt;Value, int&gt; VPair; };  extern StringPool pool;  }  #endif\t\/\/ _STRING_POOL_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">StringPool.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;StringPool.h&quot;  namespace mf2 {  StringPool pool;  void StringPool::init(){ \tusage = new map&lt;Value, int&gt;(); }  void StringPool::release() { \tfor (VIter p = usage-&gt;begin(); p != usage-&gt;end(); ++p) { \t\tdelete [] p-&gt;first.strValue; \t} \tdelete usage; }  bool StringPool::freeString(const char* s) { \tVIter p = usage-&gt;find(Value(s)); \tif (p != usage-&gt;end()) { \t\tif (--p-&gt;second &lt;= 0) { \t\t\tdelete [] p-&gt;first.strValue; \t\t\tusage-&gt;erase(p); \t\t} \t\treturn true; \t} \treturn false; }  const char* StringPool::getString(const char* s) { \tif (s == NULL) return s; \tVIter p = usage-&gt;find(Value(s)); \tif (p != usage-&gt;end()) { \t\tp-&gt;second++; \t\treturn p-&gt;first.strValue; \t} \tint sz = strlen(s) + 1; \tchar* r = new char[sz]; \tmemset(r, 0, sz); \tstrcpy(r, s); \tusage-&gt;insert(VPair(Value(r), 1)); \treturn r; }  const char* StringPool::getString(char c) { \tchar s[2]; \ts[0] = c; s[1] = 0; \treturn getString(s); }  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">StringValue.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _STRING_VALUE_H_ #define _STRING_VALUE_H_  #include &quot;s3eTypes.h&quot;  namespace mf2 {  class StringValue { \t\tconst char* strValue; \tpublic: \t\tStringValue(): strValue(NULL) {} \t\tStringValue(char c); \t\tStringValue(const char* s); \t\tStringValue(const StringValue& p); \t\t~StringValue();  \t\tbool  isString() const {return true;} \t\tbool  isNull() const {return (strValue == NULL);} \t\tvoid  clear(); \t\tconst char* getString() const;  \t\tbool  operator&lt;(const StringValue& p)  const; \t\tbool  operator&gt;(const StringValue& p)  const; \t\tbool  operator&lt;=(const StringValue& p) const {return !(*this &gt; p);} \t\tbool  operator&gt;=(const StringValue& p) const {return !(*this &lt; p);} \t\tbool  operator!=(const StringValue& p) const {return  (*this &lt; p) || (*this &gt; p);} \t\tbool  operator==(const StringValue& p) const {return !(*this != p);}  \t\tStringValue& operator=(const StringValue& p); };  }  #endif\t\/\/ _STRING_VALUE_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">StringValue.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;StringValue.h&quot; #include &quot;StringPool.h&quot;  namespace mf2 {  StringValue::StringValue(const char* s): strValue(pool.getString(s)) {} StringValue::StringValue(const StringValue& p): strValue(pool.getString(p.strValue)) {} StringValue::StringValue(char c): strValue(pool.getString(c)) {}  StringValue::~StringValue() { \tclear(); }  const char* StringValue::getString() const { \tif (isNull()) { \t\treturn &quot;&quot;; \t} else { \t\treturn strValue; \t} }  void StringValue::clear() { \tif (strValue != NULL) { \t\tpool.freeString(strValue); \t\tstrValue = NULL; \t} }  bool StringValue::operator&lt;(const StringValue& p) const { \tif (isNull()) { \t\tif (p.isNull()) return false; \t\telse return true; \t} \treturn strcmp(getString(), p.getString()) &lt; 0; }  bool StringValue::operator&gt;(const StringValue& p) const { \tif (p.isNull()) { \t\tif (isNull()) return false; \t\telse return true; \t} \treturn strcmp(getString(), p.getString()) &gt; 0; }  StringValue& StringValue::operator=(const StringValue& p) { \tif (this != &p) { \t\tstrValue = pool.getString(p.strValue); \t} \treturn *this; }  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435. \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0432\u044b\u0448\u0435, \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430\u043c\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">AbstractConfigurable.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _ABSTRACT_CONFIGURABLE_H_ #define _ABSTRACT_CONFIGURABLE_H_  #include &quot;s3eTypes.h&quot;  namespace mf2 {  class AbstractConfigurable { \tprivate: \t\tint state; \tprotected: \t\tvirtual AbstractConfigurable* createContext(const char* name) {return NULL;} \t\tvirtual bool setValue(const char* name, const char* value) = 0; \t\tvirtual bool closeContext() {return true;} \tpublic: \t\tint getState() const {return state;} \t\tvoid setState(int s) {state = s;}  \tfriend class Loader; \tfriend class Template; };  }  #endif\t\/\/ _ABSTRACT_CONFIGURABLE_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0433\u043e. \u041c\u0435\u0442\u043e\u0434\u044b createContext, closeContext \u0438 setValue \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u043e\u043c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0440\u0430\u0437\u0431\u043e\u0440\u0430 JSON-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f. \u041e\u0431\u044a\u0435\u043a\u0442, \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439 \u044d\u0442\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0441\u043c\u043e\u0436\u0435\u0442 \u043b\u0438\u0431\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u0445 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u043b\u0438\u0431\u043e \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 (\u043d\u0438\u0436\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f). \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0440\u0430\u0437\u0431\u043e\u0440\u0430, \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0435\u0433\u043e \u0440\u0430\u0437\u0431\u043e\u0440. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e state \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u0437\u0430\u0439\u043c\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 Loader:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Loader.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _LOADER_H_ #define _LOADER_H_  #include &lt;stack&gt; #include &lt;map&gt; #include &lt;yaml.h&gt; #include &quot;AbstractConfigurable.h&quot; #include &quot;Template.h&quot; #include &quot;StringValue.h&quot;  #define MAX_NAME_SZ           80  #define TEMPLATES_SCOPE       &quot;templates&quot; #define TEMPLATE_PROPERTY     &quot;template&quot;  using namespace std;  namespace mf2 {  \tclass Loader: public AbstractConfigurable { \tprivate: \t\tenum { \t\t\tstTop       = 0, \t\t\tstTemplates = 1, \t\t\tstTemplate  = 2 \t\t}; \t\tstruct Scope { \t\t\tScope(AbstractConfigurable* c, int s = 0): ctx(c), state(s) {} \t\t\tScope(const Scope& p): ctx(p.ctx), state(p.state) {} \t\t\tAbstractConfigurable* ctx; \t\t\tint state; \t\t};         yaml_parser_t                 parser;         yaml_event_t                  evnt; \t\tstack&lt;Scope&gt;                  scopes; \t\tmap&lt;StringValue, Template*&gt;   templates; \t\tint                           deep; \t\tchar                          currentName[MAX_NAME_SZ]; \t\tvoid                          clearCurrentName();         bool                          notify(AbstractConfigurable* ctx); \t\tvirtual AbstractConfigurable* createContext(const char* name); \t\tvirtual bool                  setValue(const char* name, const char* value); \t\tvirtual bool                  closeContext(); \t\tvoid                          dropTemplates(int level = 0); \t\tbool                          applyTemplate(const char* name); \tpublic: \t\tLoader(); \t\t~Loader(); \t\tbool                          load(const char* name, AbstractConfigurable* ctx);  \ttypedef map&lt;StringValue, Template*&gt;::iterator TIter; \ttypedef pair&lt;StringValue, Template*&gt; TPair; };  }  #endif\t\/\/ _LOADER_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Loader.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;Loader.h&quot; #include &lt;string.h&gt;  namespace mf2 {  Loader::Loader(): scopes(), templates(), deep(0) {}  Loader::~Loader() { \tdropTemplates(); }  void Loader::clearCurrentName() { \tmemset(currentName, 0, sizeof(currentName)); }  bool Loader::load(const char* name, AbstractConfigurable* ctx) { \tbool r = true; \tsetState(stTop);  \tscopes.push(Scope(ctx, ctx-&gt;getState())); \tclearCurrentName();     yaml_parser_initialize(&parser);     FILE* input = fopen(name, &quot;rb&quot;); \tif (input != NULL) { \t\tyaml_parser_set_input_file(&parser, input); \t\tint done = 0; \t\twhile (!done) { \t        if (!yaml_parser_parse(&parser, &evnt)) { \t\t        r = false; \t\t\t} \t\t\tif (!notify(ctx)) { \t\t\t\tr = false; \t\t\t} \t\t\tif (!r) break; \t\t\tdone = (evnt.type == YAML_STREAM_END_EVENT); \t\t\tyaml_event_delete(&evnt); \t\t} \t    fclose(input); \t} else { \t\tr = true; \t}     yaml_parser_delete(&parser); \treturn r; }  bool Loader::notify(AbstractConfigurable* ctx) { \tbool r = true;     switch (evnt.type) {         case YAML_MAPPING_START_EVENT:         case YAML_SEQUENCE_START_EVENT: \t\t\tr = (createContext(currentName) != NULL); \t\t\tclearCurrentName(); \t\t\tbreak;         case YAML_MAPPING_END_EVENT:         case YAML_SEQUENCE_END_EVENT: \t\t\tif (!closeContext()) return false;             break;         case YAML_SCALAR_EVENT: \t\t\tif (currentName[0] == 0) { \t\t\t\tstrncpy(currentName, (const char*)evnt.data.scalar.value,                                  sizeof(currentName) - 1); \t\t\t\tbreak; \t\t\t} \t\t\tr = setValue(currentName, (const char*)evnt.data.scalar.value); \t\t\tclearCurrentName();             break;          default:             break;     } \treturn r; }  void Loader::dropTemplates(int level) { \tfor (bool f = true; f;) { \t\tf = false; \t\tfor (TIter p = templates.begin(); p != templates.end(); ++p) { \t\t\tif (p-&gt;second-&gt;getLevel() &gt; level) { \t\t\t\tf = true; \t\t\t\tTemplate* next = p-&gt;second-&gt;getNext(); \t\t\t\tdelete p-&gt;second; \t\t\t\tif (next == NULL) { \t\t\t\t\ttemplates.erase(p); \t\t\t\t} else { \t\t\t\t\tp-&gt;second = next; \t\t\t\t} \t\t\t\tbreak; \t\t\t} \t\t} \t} }  AbstractConfigurable* Loader::createContext(const char* name) { \tif (scopes.empty()) return NULL; \tAbstractConfigurable* r = (AbstractConfigurable*)this; \tif (getState() != stTemplate) { \t\tif (strcmp(name, TEMPLATES_SCOPE) == 0) { \t\t\tscopes.push(Scope(r, stTemplates)); \t\t\treturn r; \t\t} \t\tif ((scopes.top().ctx == r) && (scopes.top().state == stTemplates)) { \t\t\tStringValue nm(name); \t\t\tTIter p = templates.find(nm); \t\t\tif (p != templates.end()) { \t\t\t\tr = p-&gt;second = new Template(name, p-&gt;second, deep++); \t\t\t} else { \t\t\t\tTemplate* t = new Template(name, NULL, deep++); \t\t\t\ttemplates.insert(TPair(nm, t)); \t\t\t\tr = (AbstractConfigurable*)t; \t\t\t} \t\t\tsetState(stTemplate); \t\t\tscopes.push(Scope(r)); \t\t\treturn r; \t\t} \t} \tAbstractConfigurable* t = scopes.top().ctx; \tif (t == (AbstractConfigurable*)this) return NULL; \tr = t-&gt;createContext(name); \tif (r != NULL) { \t\tscopes.push(Scope(r, r-&gt;getState())); \t} \tdeep++; \treturn r; }  bool Loader::closeContext() { \tbool r = true; \tif (scopes.empty()) return false; \tAbstractConfigurable* t = scopes.top().ctx; \tif (t != (AbstractConfigurable*)this) { \t\tr = scopes.top().ctx-&gt;closeContext(); \t} \tif (scopes.top().state != stTemplates) { \t\tdeep--; \t} \tscopes.pop(); \tdropTemplates(deep); \tif (!scopes.empty()) { \t\tscopes.top().ctx-&gt;setState(scopes.top().state); \t} \treturn r; }  bool Loader::setValue(const char* name, const char* value) { \tif (scopes.empty()) return false; \tif (getState() != stTemplate) { \t\tif (strcmp(name, TEMPLATE_PROPERTY) == 0) { \t\t\treturn applyTemplate(value); \t\t} \t} \tAbstractConfigurable* t = scopes.top().ctx; \tif (t == (AbstractConfigurable*)this) return false; \treturn scopes.top().ctx-&gt;setValue(name, value); }  bool Loader::applyTemplate(const char* name) { \tfor (TIter p = templates.begin(); p != templates.end(); ++p) { \t\tif (p-&gt;second-&gt;isEqual(name)) { \t\t\tp-&gt;second-&gt;setMagic(name); \t\t\treturn p-&gt;second-&gt;apply((AbstractConfigurable*)this); \t\t} \t} \treturn true; }  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u0442\u0435\u043a scopes \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u043a\u0446\u0438\u0439 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f. \u041e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u0441\u044f \u0432\u0435\u0440\u0445\u0443\u0448\u043a\u0435 \u0441\u0442\u0435\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c, \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c\u044b\u0435 YAML-\u043f\u0430\u0440\u0441\u0435\u0440\u043e\u043c \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f. \u041c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e Loader \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u043c AbstractConfigurable. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u0435\u043a\u0446\u0438\u0439 \u00abtemplates\u00bb \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u00abtemplate\u00bb \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0435\u0449\u0435 \u0434\u043e \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c. <\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 Template \u043f\u0440\u043e\u0441\u0442\u0430. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0432 \u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b, \u0447\u0442\u043e\u0431\u044b \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0438\u0445 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u043f\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Template.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _TEMPLATE_H_ #define _TEMPLATE_H_  #include &lt;vector&gt; #include &quot;AbstractConfigurable.h&quot; #include &quot;VarHolder.h&quot;  using namespace std;  namespace mf2 {  class Template: public AbstractConfigurable               , public VarHolder { \tprivate: \t\tenum { \t\t\titOpen  = 0, \t\t\titClose = 1, \t\t\titSet   = 2 \t\t}; \t\tstruct Item { \t\t\tItem(const char* nm = NULL, const char* vl = NULL): name(nm), value(vl) {} \t\t\tItem(const Item& p): name(p.name), value(p.value) {} \t\t\tStringValue name; \t\t\tStringValue value; \t\t\tint getType() const; \t\t}; \t\tint             deep; \t\tTemplate*       next; \t\tint             level; \t\tvector&lt;Item&gt;    items; \tpublic: \t\tTemplate(const char* name, Template* t, int l);  \t\tvirtual AbstractConfigurable* createContext(const char* name); \t\tvirtual bool setValue(const char* name, const char* value); \t\tvirtual bool closeContext();  \t\tint       getLevel() const {return level;} \t\tTemplate* getNext() {return next;} \t\tbool      apply(AbstractConfigurable* ctx);  \ttypedef vector&lt;Item&gt;::iterator IIter; };  }  #endif\t\/\/ _TEMPLATE_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Template.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;Template.h&quot;  #include &quot;s3eTypes.h&quot;  namespace mf2 {  Template::Template(const char* name, Template* t, int l): AbstractConfigurable(), VarHolder(NULL, name), next(t), level(l), items(), deep(0) {}  int Template::Item::getType() const { \tif (name.isNull()) { \t\treturn itClose; \t} \tif (value.isNull()) { \t\treturn itOpen; \t} \treturn itSet; }  AbstractConfigurable* Template::createContext(const char* name) { \titems.push_back(Item(name)); \tdeep++; \treturn this; }  bool Template::setValue(const char* name, const char* value) { \titems.push_back(Item(name, value)); \treturn true; }  bool Template::closeContext() { \tif (deep == 0) return true; \tdeep--; \titems.push_back(Item()); \treturn true; }  bool Template::apply(AbstractConfigurable* ctx) { \tfor (IIter p = items.begin(); p != items.end(); ++p) { \t\tswitch (p-&gt;getType()) { \t\t\tcase itOpen: \t\t\t\tif (ctx-&gt;createContext(p-&gt;name.getString()) == NULL) return false; \t\t\t\tbreak; \t\t\tcase itClose: \t\t\t\tif (!ctx-&gt;closeContext()) return false; \t\t\t\tbreak; \t\t\tcase itSet: {\t \t\t\t\t\tValue v(p-&gt;value.getString()); \t\t\t\t\tmagicValue(v); \t\t\t\t\tif (!ctx-&gt;setValue(p-&gt;name.getString(), v.getString())) return false; \t\t\t\t} \t\t\t\tbreak; \t\t} \t} \treturn true; }  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0440\u0430\u0437 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e Template \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442 AbstractConfigurable, \u043d\u043e \u0438 \u043e\u0442 VarHolder, \u044f\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e Runtime-\u0430. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u00ab\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435\u00bb \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<pre><code>               wt_N:   { action:      w_N,                          name:        wr_N,                          template:    lock,                          x:           1,                          template:    y,                          width:      -1,                          height:      30,                          image:       w_N                        }, <\/code><\/pre>\n<p>  \u0417\u0430\u0433\u043b\u0430\u0432\u043d\u044b\u0435 \u0431\u0443\u043a\u0432\u044b \u0432 \u0438\u043c\u0435\u043d\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u00abwt_1\u00bb, \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u00abN\u00bb, \u0438\u043c\u0435\u044e\u0449\u0430\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1. \u0412\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0435 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435 (\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438) \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u043c\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 &#8216;N&#8217;. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b &#8216;1&#8217;.<\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">VarHolder.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _VAR_HOLDER_H_ #define _VAR_HOLDER_H_  #include &lt;map&gt; #include &quot;StringValue.h&quot; #include &quot;Value.h&quot;  using namespace std;  namespace mf2 {  class VarHolder { \tprivate: \t\tVarHolder* parent; \t\tStringValue name; \t\tmap&lt;StringValue, Value&gt; values; \t\tvoid addMagic(); \t\tint  getMagicValue(char c); \tprotected: \t\tvoid magicValue(Value& v); \tpublic: \t\tVarHolder(VarHolder* p, const char* nm = &quot;&quot;); \t\tvoid setMagic(const char* actualName); \t\tbool isEqual(const char* actualName); \t\tstatic bool isEmpty(const char* v);  \t\ttemplate&lt;class T&gt; \t\tvoid defVar(const char* name, T value); \t\ttemplate&lt;class T&gt; \t\tvoid setVar(const char* name, T value); \t\tbool isExists(const char* name); \t\tconst char* getString(const char* name); \t\tint getInt(const char* name);  \ttypedef map&lt;StringValue, Value&gt;::iterator VIter; \ttypedef pair&lt;StringValue, Value&gt; VPair; };  }  #endif\t\/\/ _VAR_HOLDER_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">VarHolder.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;VarHolder.h&quot; #include &lt;string.h&gt;  namespace mf2 {  VarHolder::VarHolder(VarHolder* p, const char* nm): name(nm), parent(p), values() { \taddMagic(); }  template&lt;class T&gt; void VarHolder::defVar(const char* name, T value) { \tVIter p = values.find(StringValue(name)); \tif (p != values.end()) { \t\tp-&gt;second = Value(value); \t} else { \t\tvalues.insert(VPair(StringValue(name), Value(value))); \t} }  template&lt;class T&gt; void VarHolder::setVar(const char* name, T value) { \tVIter p = values.find(StringValue(name)); \tif (p != values.end()) { \t\tp-&gt;second = Value(value); \t\treturn; \t} \tif (parent != NULL) { \t\tparent-&gt;setVar(name, value); \t} }  bool VarHolder::isExists(const char* name) { \tVIter p = values.find(StringValue(name)); \tif (p != values.end()) { \t\treturn true; \t} \tif (parent != NULL) { \t\treturn parent-&gt;isExists(name); \t} \treturn false; }  const char* VarHolder::getString(const char* name) { \tVIter p = values.find(StringValue(name)); \tif (p != values.end()) { \t\treturn p-&gt;second.getString(); \t} \tif (parent != NULL) { \t\treturn parent-&gt;getString(name); \t} \treturn &quot;&quot;; }  int VarHolder::getInt(const char* name) { \tVIter p = values.find(StringValue(name)); \tif (p != values.end()) { \t\treturn p-&gt;second.getInt(); \t} \tif (parent != NULL) { \t\treturn parent-&gt;getInt(name); \t} \treturn 0; }  void VarHolder::addMagic() { \tconst char* s = name.getString(); \tfor (int i = 0; i &lt; (int)strlen(s); i++) { \t\tif ((s[i] &gt;= 'A')&&(s[i] &lt;= 'Z')) { \t\t\tdefVar(StringValue(s[i]).getString(), 0); \t\t} \t} }  int VarHolder::getMagicValue(char c) { \tif ((c &gt;= '0') && (c &lt;= '9')) { \t\treturn (int)(c - '0'); \t} \tif ((c &gt;= 'a') && (c &lt;= 'z')) { \t\treturn (int)(c - 'a' + 10); \t} \treturn -1; }  void VarHolder::setMagic(const char* actualName) { \tconst char* s = name.getString(); \tfor (int i = 0; i &lt; (int)strlen(s); i++) { \t\tif (i &gt;= (int)strlen(actualName)) break; \t\tif ((s[i] &gt;= 'A')&&(s[i] &lt;= 'Z')) { \t\t\tint v = getMagicValue(actualName[i]); \t\t\tif (v &gt;= 0) { \t\t\t\tsetVar(StringValue(s[i]).getString(), v); \t\t\t} \t\t} \t} }  bool VarHolder::isEqual(const char* actualName) { \tconst char* s = name.getString(); \tfor (int i = 0; i &lt; (int)strlen(s); i++) { \t\tif (i &gt;= (int)strlen(actualName)) return false; \t\tif ((s[i] &gt;= 'A')&&(s[i] &lt;= 'Z')) continue; \t\tif (s[i] != actualName[i]) return false; \t} \treturn true; }  bool VarHolder::isEmpty(const char* v) { \tif (v == NULL) return true; \tif (v[0] == 0) return true; \treturn false; }  void VarHolder::magicValue(Value& v) { \tconst char* value = v.getString(); \tfor (int i = 0; i &lt; (int)strlen(value); i++) { \t\tif ((value[i] &gt;= 'A')&&(value[i] &lt;= 'Z')) { \t\t\tStringValue name(value[i]); \t\t\tif (isExists(name.getString())) { \t\t\t\tconst char* vl = getString(name.getString()); \t\t\t\tif (!isEmpty(vl)) { \t\t\t\t\tv.replace(i, vl[0]); \t\t\t\t\tvalue = v.getString(); \t\t\t\t} \t\t\t} \t\t} \t} }  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e. \u041f\u0440\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0435\u0433\u043e \u0438\u043c\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c addMagic, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0430 \u043f\u0435\u0440\u0435\u0434 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u043e\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c setMagic, \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0449\u0438\u043c \u044d\u0442\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041c\u0435\u0442\u043e\u0434 magicValue \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 (\u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0435, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e).<\/p>\n<p>  \u0420\u0430\u0437\u0431\u043e\u0440 JSON-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u0442\u0441\u044f ScopeManager-\u043e\u043c (\u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u043c\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e Runtime-\u0430). \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432, \u043f\u043e\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0445 \u0441\u0435\u043a\u0446\u0438\u0439 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">ScopeManager.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _SCOPE_MANAGER_H_ #define _SCOPE_MANAGER_H_  #include &lt;map&gt; #include &lt;queue&gt; #include &quot;AbstractConfigurable.h&quot; #include &quot;ScopeDef.h&quot;  using namespace std;  #define MAIN_CONFIG     &quot;main.json&quot;  #define DISPLAY_SCOPE   &quot;display&quot; #define SCOPES_SCOPE    &quot;scopes&quot;  #define LOAD_PROPERTY   &quot;load&quot;  namespace mf2 {  class ScopeManager: public AbstractConfigurable { \tprivate: \t\tenum { \t\t\tstTop       = 0, \t\t\tstScopes    = 1 \t\t}; \t\tqueue&lt;const char*&gt;* files; \t\tmap&lt;StringValue, ScopeDef*&gt;* scopes; \t\tbool load(const char* name); \t\tvoid deepIncrement(); \t\tvoid deepDecrement(); \t\tvirtual AbstractConfigurable* createContext(const char* name); \t\tvirtual bool setValue(const char* name, const char* value); \tpublic: \t\tbool init(); \t\tvoid release();  \ttypedef map&lt;StringValue, ScopeDef*&gt;::iterator SIter; \ttypedef pair&lt;StringValue, ScopeDef*&gt; SPair;  \tfriend class AbstractConfigurable; };  extern ScopeManager sm;  }  #endif\t\/\/ _SCOPE_MANAGER_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">ScopeManager.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;ScopeManager.h&quot; #include &quot;ConfigLoader.h&quot; #include &quot;StringPool.h&quot; #include &quot;Desktop.h&quot;  namespace mf2 {  ScopeManager sm;  bool ScopeManager::init() { \tsetState(stTop); \tdesktop.init(); \tpool.init(); \tfiles = new queue&lt;const char*&gt;(); \tscopes = new map&lt;StringValue, ScopeDef*&gt;(); \treturn load(MAIN_CONFIG); }  void ScopeManager::release() { \tfor (SIter p = scopes-&gt;begin(); p != scopes-&gt;end(); ++p) { \t\tdelete p-&gt;second; \t} \tdelete scopes; \tdelete files; \tpool.release(); \tdesktop.release(); }  bool ScopeManager::load(const char* name) { \tLoader loader; \tsetState(stTop); \tfiles-&gt;push(pool.getString(name)); \twhile (!files-&gt;empty()) { \t\tconst char* fn = files-&gt;front(); \t\tfiles-&gt;pop(); \t\tif (!loader.load(fn, (AbstractConfigurable*)this)) return false; \t\tpool.freeString(fn); \t} \treturn true; }  AbstractConfigurable* ScopeManager::createContext(const char* name) { \tif (getState() == stTop) { \t\tif (strcmp(name, DISPLAY_SCOPE) == 0) { \t\t\treturn &desktop; \t\t} \t\tif (strcmp(name, SCOPES_SCOPE) == 0) { \t\t\tsetState(stScopes); \t\t\treturn this; \t\t} \t} \tif (getState() == stScopes) { \t\tScopeDef* r = new ScopeDef; \t\tscopes-&gt;insert(SPair(StringValue(name), r)); \t\treturn r; \t} \treturn (AbstractConfigurable*)this; }  bool ScopeManager::setValue(const char* name, const char* value) { \tif (getState() == stTop) { \t\tif (strcmp(name, LOAD_PROPERTY) == 0) { \t\t\tfiles-&gt;push(pool.getString(value)); \t\t\treturn true; \t\t} \t} \treturn false; }  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0440\u0430\u0437\u0431\u043e\u0440 \u0441\u0435\u043a\u0446\u0438\u0438 \u00abdisplay\u00bb \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0443 display, \u0430 \u0442\u0430\u043a\u0436\u0435, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f ScopeDef. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 ScopeDef, RegionDef \u0438 VarDef \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430 (\u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/GlukKazan\/mf2\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>, \u044f \u043d\u0435 \u0441\u0442\u0430\u043d\u0443 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u0445 \u0437\u0434\u0435\u0441\u044c), \u0430 \u043a\u043b\u0430\u0441\u0441 Display \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0437\u0434\u043d\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 Runtime.<\/p>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0442\u0443\u0434\u0430, \u043a\u0443\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0440\u0430\u0437\u0440\u0443\u0448\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u043c\u044f\u0442\u044c:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Main.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;ScopeManager.h&quot;  using namespace mf2;  void init() {      sm.init(); }  void release() {      sm.release(); }  int main() {     init();       release();     return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c, \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f, \u0432\u0441\u0435. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 Runtime.      \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/171237\/\"> http:\/\/habrahabr.ru\/post\/171237\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 <a href=\"https:\/\/github.com\/GlukKazan\/mf2\">Marmalade Framework<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0435\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b <a href=\"http:\/\/habrahabr.ru\/post\/170255\/\">\u0440\u0430\u043d\u0435\u0435<\/a>. \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u0448\u0430\u0433\u0435, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 (templates), \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-171237","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/171237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=171237"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/171237\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=171237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=171237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=171237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}