{"id":1436,"date":"2014-12-11T16:07:21","date_gmt":"2014-12-11T08:07:21","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=1436"},"modified":"2014-12-11T16:07:57","modified_gmt":"2014-12-11T08:07:57","slug":"qmacros%e5%ae%8f%e7%9a%84%e5%80%bc%e7%a8%b3%e5%ae%9a%e6%80%a7%e9%80%89%e9%a1%b9%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=1436","title":{"rendered":"QMacros\u5b8f\u7684\u503c\u7a33\u5b9a\u6027\u9009\u9879\u8be6\u89e3"},"content":{"rendered":"<p>QMacros\u5b8f\u7684\u7a33\u5b9a\u6027\uff0c\u7cfb\u7edf\u7ed9\u4e86\u4e00\u4e2a\u679a\u4e3e\u7c7b\u578bTQMacroVolatile\u6765\u8868\u793a\uff0c\u5b83\u5b9a\u4e49\u7684\u6b63\u786e\u4e0e\u5426\uff0c\u4f1a\u5f71\u54cd\u6574\u4f53\u66ff\u6362\u64cd\u4f5c\u7684\u6548\u7387\u3002\u6211\u4eec\u5148\u770b\u5176\u5b9a\u4e49\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">  \/\/\/ &lt;summary&gt;\u5b8f\u5b9a\u4e49\u503c\u7684\u7a33\u5b9a\u6027\u5b9a\u4e49&lt;\/summary&gt;\r\n  \/\/\/ &lt;param name=\"mvImmutable\"&gt;\u503c\u662f\u56fa\u5b9a\u4e0d\u53d8\u7684\uff0c\u662f\u4e00\u79cd\u5e38\u91cf\u72b6\u6001&lt;\/param&gt;\r\n  \/\/\/ &lt;param name=\"mvStable\"&gt;\u503c\u662f\u76f8\u5bf9\u4e0d\u53d8\u7684\uff0c\u5728\u4e00\u6b21\u66ff\u6362\u64cd\u4f5c\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u8ba4\u4e3a\u5176\u7b49\u4ef7\u53d1mvImmutable&lt;\/param&gt;\r\n  \/\/\/ &lt;param name=\"mvVolatile\"&gt;\u503c\u662f\u6613\u53d8\u7684\uff0c\u6bcf\u6b21\u83b7\u53d6\u5b8f\u7684\u503c\u65f6\uff0c\u8fd4\u56de\u7684\u503c\u90fd\u53ef\u80fd\u662f\u4e0d\u540c\u7684&lt;\/param&gt;\r\n  TQMacroVolatile = (mvImmutable, mvStable, mvVolatile);<\/pre>\n<p>\u8fd9\u4e09\u79cd\u4e0d\u540c\u7684\u9009\u62e9\uff0c\u5f71\u54cd\u66ff\u6362\u65f6\uff0cQMacros\u5982\u4f55\u4f18\u5316\u64cd\u4f5c\u8fc7\u7a0b\uff1a<\/p>\n<p>1\u3001\u4e0d\u53d8\u7684\uff08mvImmutable\uff09<\/p>\n<p>\u6b64\u65f6\uff0c\u503c\u662f\u56fa\u5b9a\u4e0d\u53d8\u7684\uff0c\u4e0d\u7ba1\u5b8f\u4ec0\u4e48\u65f6\u5019\u8c03\u7528\uff0c\u8fd4\u56de\u503c\u59cb\u7ec8\u662f\u56fa\u5b9a\u7684\u3002\u5982\u5b9a\u4e49\u5b8fPI\u8fd4\u56de\u03c0\u7684\u503c\uff0c\u5b83\u65e0\u8bba\u4f55\u65f6\u8c03\u7528\u90fd\u8fd4\u56de\u56fa\u5b9a\u7684\u503c\u3002<\/p>\n<p>\u9ed8\u8ba4\u901a\u8fc7\u4e0b\u9762\u7684Push\u51fd\u6570\u5165\u6808\u7684\u5b8f\u90fd\u662fmvImmutable\u7c7b\u578b\u7684\u5b8f\u3002<\/p>\n<pre class=\"lang:delphi decode:true \">procedure Push(const AName, AValue: QStringW);<\/pre>\n<p>\u5982\u679c\u901a\u8fc7\u4e3a\u5b8f\u63d0\u4f9b\u4e86\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u5e76\u6307\u660e\u5176\u503c\u7c7b\u578b\u4e3amvImmutable\uff0c\u5b8f\u5728\u5b9e\u9645\u5165\u6808\u65f6\uff0c\u4f1a\u7f13\u5b58\u4e00\u6b21\u5b8f\u7684\u503c\uff0c\u4f9b\u4ee5\u540e\u8c03\u7528\u3002\u65e0\u8bba\u540e\u9762\u591a\u5c11\u6b21\u66ff\u6362\uff0c\u90fd\u53ea\u4f7f\u7528\u7b2c\u4e00\u6b21\u7684\u521d\u59cb\u503c\uff0c\u8fd9\u6837\u53ef\u4ee5\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u8c03\u7528\u5f00\u9500\uff0c\u52a0\u5feb\u66ff\u6362\u64cd\u4f5c\u7684\u5b8c\u6210\u901f\u5ea6\u3002<\/p>\n<pre class=\"lang:delphi decode:true \">procedure Push(const AName: QStringW; AOnFetchValue: TQMacroValueFetchEvent;AVolatile: TQMacroVolatile = mvVolatile; ATag: IntPtr = 0);<\/pre>\n<p>\u6211\u4eec\u770b\u4e00\u4e0b\u8fd9\u4e2a\u51fd\u6570\u5165\u6808\u65f6\u7684\u90e8\u5206\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">function NewValue: PQMacroValue;\r\n  begin\r\n  New(Result);\r\n  Result.OnFetchValue := AOnFetchValue;\r\n  Result.Prior := nil;\r\n  Result.Next := nil;\r\n  Result.Tag := ATag;\r\n  Result.SavePoint := FSavePoint;\r\n  Result.Volatile := AVolatile;\r\n  case AVolatile of\r\n    mvImmutable: \/\/ \u59cb\u7ec8\u8fd4\u56de\u56fa\u5b9a\u503c\u7684\u5b8f\uff0c\u6211\u4eec\u76f4\u63a5\u53d6\u4e00\u6b21\u503c\uff0c\u4ee5\u4fbf\u4f18\u5316\u5176\u66ff\u6362\u8fc7\u7a0b\r\n      AOnFetchValue(Self, AItem, #0, Result.Value);\r\n    mvStable:\r\n      Inc(FStableCount);\r\n    mvVolatile:\r\n      Inc(FVolatileCount);\r\n  end;\r\n  end;<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230mvImmutable\u7c7b\u578b\u7684\u51fd\u6570\u5165\u6808\u65f6\u76f4\u63a5\u83b7\u53d6\u4e86\u5176\u503c\u3002\u800c\u5728\u5185\u90e8\u83b7\u53d6\u5b8f\u7684\u53d6\u503c\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4ee3\u7801\u68c0\u67e5\u5230\u5b8f\u7684\u7a33\u5b9a\u6027\u4e3amuImmutable\u65f6\uff0c\u4f1a\u76f4\u63a5\u8fd4\u56de\u7f13\u5b58\u7684Value\u503c\u3002<\/p>\n<pre class=\"lang:delphi decode:true\">    if AItem.Value.Volatile = mvImmutable then\r\n      AValue := AItem.Value.Value\r\n    else if Assigned(AItem.Value.OnFetchValue) then\r\n      begin\r\n      if (AItem.Value.Volatile = mvVolatile) or (FReplaceRef = 0) then \/\/\r\n        AItem.Value.OnFetchValue(Self, AItem, AQuoter, AValue)\r\n      else \/\/ mvStable\r\n        begin\r\n        if AItem.Value.SavePoint &lt;&gt; FSavePoint then \/\/ \u7f13\u5b58\u5f53\u524d\u503c\r\n          begin\r\n          New(AItem.Value.Next);\r\n          AItem.Value.Next.Tag := AItem.Value.Tag;\r\n          AItem.Value.Next.OnFetchValue := nil;\r\n          AItem.Value.Next.SavePoint := FSavePoint;\r\n          AItem.Value.Next.Volatile := mvImmutable;\r\n          AItem.Value.Next.Prior := AItem.Value;\r\n          AItem.Value.Next.Next := nil;\r\n          AItem.Value.OnFetchValue(Self, AItem, #0, AValue);\r\n          AItem.Value.Next.Value := AValue;\r\n          AItem.FValue := AItem.Value.Next;\r\n          end;\r\n        end;\r\n      end<\/pre>\n<p>2\u3001\u7a33\u5b9a\u7684\uff08mvStable\uff09<\/p>\n<p>\u8fd9\u7c7b\u5b8f\u7684\u503c\u5728\u540c\u4e00\u6b21\u66ff\u6362\u8fc7\u7a0b\u4e2d\uff0c\u591a\u6b21\u8c03\u7528\u4f1a\u8fd4\u56de\u540c\u4e00\u4e2a\u503c\uff0c\u5982\u53d6\u5f53\u524d\u65f6\u95f4\u7c7b\u51fd\u6570\uff0c\u5728\u66ff\u6362\u8fc7\u7a0b\u4e2d\uff0c\u4e00\u822c\u6211\u4eec\u662f\u4e0d\u53d8\u7684\uff0c\u6240\u4ee5\u5b83\u7684\u7a33\u5b9a\u6027\u6211\u4eec\u4e00\u822c\u8bbe\u7f6e\u4e3amvStable\u3002<\/p>\n<p>\u56e0\u4e3a\u8fd9\u7c7b\u503c\u5728\u5355\u6b21\u66ff\u6362\u65f6\uff0c\u5176\u503c\u662f\u56fa\u5b9a\u4e0d\u53d8\u7684\uff0c\u6240\u4ee5\uff0c\u66ff\u6362\u64cd\u4f5c\u5bf9\u6b64\u7684\u4f18\u5316\u662f\u53d1\u73b0\u662f\u7b2c\u4e00\u6b21\u8bbf\u95ee\u8be5\u5b8f\u65f6\uff0c\u7f13\u5b58\u8be5\u503c\u4e3a\u5e76\u5165\u6808\u4e3amvImmutable\uff0c\u8fd9\u6837\u5b50\u540e\u9762\u8bfb\u53d6\u8be5\u5b8f\u7684\u503c\u65f6\uff0c\u90fd\u548cmvImmutable\u7684\u5904\u7406\u5b8c\u5168\u4e00\u6837\uff0c\u4ece\u800c\u4e0d\u518d\u9700\u8981\u8fdb\u884c\u51fd\u6570\u8c03\u7528\u3002<\/p>\n<p>3\u3001\u6613\u53d8\u7684\uff08mvVolatile\uff09<\/p>\n<p>\u8fd9\u7c7b\u5b8f\u7684\u503c\u662f\u6613\u53d8\u7684\uff0c\u6bcf\u6b21\u8c03\u7528\u90fd\u4f1a\u8fd4\u56de\u5b8c\u5168\u4e0d\u540c\u7684\u503c\u3002\u8fd9\u7c7b\u51fd\u6570\u7531\u4e8e\u6bcf\u6b21\u5b8f\u66ff\u6362\u65f6\u90fd\u8fd4\u56de\u4e0d\u540c\u7684\u503c\uff0c\u56e0\u6b64\uff0c\u5728\u66ff\u6362\u65f6\u6211\u4eec\u9700\u8981\u6309\u6700\u7cdf\u7cd5\u7684\u60c5\u51b5\u6765\u8003\u8651\u3002\u6bcf\u6b21\u9700\u8981\u66ff\u6362\u65f6\uff0c\u90fd\u4f1a\u8c03\u7528OnFetchValue\u5bf9\u5e94\u7684\u56de\u8c03\u51fd\u6570\u6765\u83b7\u53d6\u8be5\u503c\u3002<\/p>\n<p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u6211\u4eec\u53ef\u4ee5\u603b\u7ed3\u5982\u4e0b\uff1a<\/p>\n<p>\uff081\uff09\u5bf9\u4e8emvImmutable\u7c7b\u578b\u7684\u5b8f\uff0c\u5176OnFetchValue\u53ea\u5728\u6ce8\u518c\u65f6\u89e6\u53d1\u4e00\u6b21\uff0c\u4ee5\u540e\u4e0d\u518d\u89e6\u53d1\u3002<\/p>\n<p>\uff082\uff09\u5bf9\u4e8emvStable\u7c7b\u578b\u7684\u5b8f\uff0c\u5176OnFetchValue\u5728\u6bcf\u6b21\u6267\u884cReplace\u51fd\u6570\u65f6\u89e6\u53d1\uff0c\u5728\u540c\u4e00\u6b21\u66ff\u6362\u64cd\u4f5c\u65f6\uff0c\u4e0d\u4f1a\u91cd\u590d\u89e6\u53d1\u3002<\/p>\n<p>\uff083\uff09\u5bf9\u4e8emvVolatile\u7c7b\u578b\u7684\u5b8f\uff0c\u5176OnFetchValue\u5728\u6bcf\u6b21\u9047\u5230\u9700\u8981\u89e3\u6790\u8be5\u5b8f\u7684\u503c\u65f6\u90fd\u4f1a\u89e6\u53d1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>QMacros\u5b8f\u7684\u7a33\u5b9a\u6027\uff0c\u7cfb\u7edf\u7ed9\u4e86\u4e00\u4e2a\u679a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[69,9,214],"tags":[219,221,220,216,222],"class_list":["post-1436","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-qdac","category-qmacros","tag-mvimmutable","tag-mvstable","tag-mvvolatile","tag-216","tag-222"],"views":5307,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1436"}],"version-history":[{"count":2,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1436\/revisions"}],"predecessor-version":[{"id":1438,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/1436\/revisions\/1438"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}