http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/faq.zh-cn.md ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/faq.zh-cn.md b/thirdparty/rapidjson-1.1.0/doc/faq.zh-cn.md new file mode 100644 index 0000000..ed100e1 --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/faq.zh-cn.md @@ -0,0 +1,290 @@ +# 常è§é®é¢ + +[TOC] + +## ä¸è¬é®é¢ + +1. RapidJSON æ¯ä»ä¹ï¼ + + RapidJSON æ¯ä¸ä¸ª C++ åºï¼ç¨äºè§£æåçæ JSONã读è å¯åèå®çææ [ç¹ç¹](doc/features.zh-cn.md)ã + +2. 为ä»ä¹ç§°ä½ RapidJSONï¼ + + å®ççµææ¥èªäº [RapidXML](http://rapidxml.sourceforge.net/)ï¼RapidXML æ¯ä¸ä¸ªé«éç XML DOM 解æå¨ã + +3. RapidJSON ä¸ RapidXML ç¸ä¼¼ä¹ï¼ + + RapidJSON åéäº RapidXML çä¸äºè®¾è®¡, å æ¬åä½ï¼*in situ*ï¼è§£æãåªæ头æ件çåºãä½ä¸¤è ç API æ¯å®å ¨ä¸åçãæ¤å¤ RapidJSON ä¹æä¾è®¸å¤ RapidXML 没æçç¹ç¹ã + +4. RapidJSON æ¯å è´¹çä¹ï¼ + + æ¯çï¼å®å¨ MIT ç¹è¨±æ¢æ¬¾ä¸å è´¹ãå®å¯ç¨äºåä¸è½¯ä»¶ã详æ 请åç [license.txt](https://github.com/miloyip/rapidjson/blob/master/license.txt)ã + +5. RapidJSON å¾å°ä¹ï¼å®æä½ä¾èµï¼ + + æ¯çãå¨ Windows ä¸ï¼ä¸ä¸ªè§£æ JSON 并æå°åºç»è®¡çå¯æ§è¡æ件å°äº 30KBã + + RapidJSON ä» ä¾èµäº C++ æ ååºã + +6. ææ ·å®è£ RapidJSONï¼ + + è§ [å®è£ ä¸è](../readme.zh-cn.md#å®è£ )ã + +7. RapidJSON è½å¦è¿è¡äºæçå¹³å°ï¼ + + 社åºå·²å¨å¤ä¸ªæä½ç³»ç»ï¼ç¼è¯å¨ï¼CPU æ¶æçç»åä¸æµè¯ RapidJSONãä½æ们æ æ³ç¡®ä¿å®è½è¿è¡äºä½ ç¹å®çå¹³å°ä¸ãåªéè¦çæåæ§è¡åå æµè¯ä¾¿è½è·åçæ¡ã + +8. RapidJSON æ¯æ C++03 ä¹ï¼C++11 å¢ï¼ + + RapidJSON å¼å§æ¶å¨ C++03 ä¸å®ç°ãåæ¥å å ¥äºå¯éç C++11 ç¹æ§æ¯æï¼å¦è½¬ç§»æé å½æ°ã`noexcept`ï¼ãRapidJSON åºè¯¥å ¼å®¹ææéµä» C++03 æ C++11 çç¼è¯å¨ã + +9. RapidJSON æ¯å¦ççç¨äºå®é åºç¨ï¼ + + æ¯çãå®è¢«é ç½®äºåå°ååå°ççå®åºç¨ä¸ãä¸ä¸ªç¤¾åºæå说 RapidJSON å¨ä»ä»¬çç³»ç»ä¸æ¯æ¥è§£æ 5 åä¸ä¸ª JSONã + +10. RapidJSON æ¯å¦ä½è¢«æµè¯çï¼ + + RapidJSON å å«ä¸ç»åå æµè¯å»æ§è¡èªå¨æµè¯ã[Travis](https://travis-ci.org/miloyip/rapidjson/)ï¼ä¾ Linux å¹³å°ï¼å [AppVeyor](https://ci.appveyor.com/project/miloyip/rapidjson/)ï¼ä¾ Windows å¹³å°ï¼ä¼å¯¹ææä¿®æ¹è¿è¡ç¼è¯åæ§è¡åå æµè¯ãå¨ Linux ä¸è¿ä¼ä½¿ç¨ Valgrind å»æ£æµå åæ³æ¼ã + +11. RapidJSON æ¯å¦æå®æ´çææ¡£ï¼ + + RapidJSON æä¾äºä½¿ç¨æåå API 说æææ¡£ã + +12. æ没æå ¶ä»æ¿ä»£åï¼ + + æ许å¤æ¿ä»£åãä¾å¦ [nativejson-benchmark](https://github.com/miloyip/nativejson-benchmark) ååºäºä¸äºå¼æºç C/C++ JSON åºã[json.org](http://www.json.org/) ä¹æä¸ä¸ªå表ã + +## JSON + +1. ä»ä¹æ¯ JSONï¼ + + JSON (JavaScript Object Notation) æ¯ä¸ä¸ªè½»éçæ°æ®äº¤æ¢æ ¼å¼ãå®ä½¿ç¨äººç±»å¯è¯»çææ¬æ ¼å¼ãæ´å¤å ³äº JSON çç»èå¯è [RFC7159](http://www.ietf.org/rfc/rfc7159.txt) å [ECMA-404](http://www.ecma-international.org/publications/standards/Ecma-404.htm)ã + +2. JSON æä»ä¹åºç¨åºåï¼ + + JSON 常ç¨äºç½é¡µåºç¨ç¨åºï¼ä»¥ä¼ éç»æåæ°æ®ãå®ä¹å¯ä½ä¸ºæä»¶æ ¼å¼ç¨äºæ°æ®æä¹ åã + +2. RapidJSON æ¯å¦ç¬¦å JSON æ åï¼ + + æ¯ãRapidJSON å®å ¨ç¬¦å [RFC7159](http://www.ietf.org/rfc/rfc7159.txt) å [ECMA-404](http://www.ecma-international.org/publications/standards/Ecma-404.htm)ãå®è½å¤çä¸äºç¹æ®æ åµï¼ä¾å¦æ¯æ JSON å符串ä¸å«æ空å符å代ç对ï¼surrogate pairï¼ã + +3. RapidJSON æ¯å¦æ¯æ宽æ¾çè¯æ³ï¼ + + ç°æ¶ä¸æ¯æãRapidJSON åªæ¯æä¸¥æ ¼çæ åæ ¼å¼ã宽æ¾è¯æ³ç°æ¶å¨è¿ [issue](https://github.com/miloyip/rapidjson/issues/36) ä¸è¿è¡è®¨è®ºã + +## DOM ä¸ SAX + +1. ä»ä¹æ¯ DOM é£æ ¼ APIï¼ + + Document Object Modelï¼DOMï¼æ¯ä¸ä¸ªå¨åäºå åç JSON 表示æ¹å¼ï¼ç¨äºæ¥è¯¢åä¿®æ¹ JSONã + +2. ä»ä¹æ¯ SAX é£æ ¼ API? + + SAX æ¯ä¸ä¸ªäºä»¶é©±å¨ç APIï¼ç¨äºè§£æåçæ JSONã + +3. æåºç¨ DOM è¿æ¯ SAXï¼ + + DOM æäºæ¥è¯¢åä¿®æ¹ãSAX åæ¯é常快åçå åçï¼ä½é常è¾é¾ä½¿ç¨ã + +4. ä»ä¹æ¯åä½ï¼*in situ*ï¼è§£æï¼ + + åä½è§£æä¼æ JSON å符串ç´æ¥è§£ç è³è¾å ¥ç JSON ä¸ãè¿æ¯ä¸ä¸ªä¼åï¼å¯åå°å åæ¶èåæåæ§è½ï¼ä½è¾å ¥ç JSON ä¼è¢«æ´æ¹ãè¿ä¸æ¥ç»è请åè [åä½è§£æ](doc/dom.zh-cn.md) ã + +5. ä»ä¹æ¶åä¼äº§ç解æéè¯¯ï¼ + + å½è¾å ¥ç JSON å å«éæ³è¯æ³ï¼æä¸è½è¡¨ç¤ºä¸ä¸ªå¼ï¼å¦ Number 太大ï¼ï¼æ解æå¨çå¤çå¨ä¸æ解æè¿ç¨ï¼è§£æå¨é½ä¼äº§çä¸ä¸ªé误ã详æ 请åè [解æé误](doc/dom.zh-cn.md)ã + +6. æä»ä¹é误信æ¯ï¼ + + é误信æ¯åå¨å¨ `ParseResult`ï¼å®å å«é误代å·åå移å¼ï¼ä» JSON å¼å§è³é误å¤çå符æ°ç®ï¼ãå¯ä»¥æé误代å·ç¿»è¯ä¸ºäººç±»å¯è¯»çé误讯æ¯ã + +7. 为ä½ä¸åªä½¿ç¨ `double` å»è¡¨ç¤º JSON numberï¼ + + ä¸äºåºç¨éè¦ä½¿ç¨ 64 ä½æ å·ï¼æå·æ´æ°ãè¿äºæ´æ°ä¸è½æ æå°è½¬æ¢æ `double`ãå æ¤è§£æå¨ä¼æ£æµä¸ä¸ª JSON number æ¯å¦è½è½¬æ¢è³åç§æ´æ°ç±»åå `double`ã + +8. å¦ä½æ¸ 空并æå°å `document` æ `value` ç容éï¼ + + è°ç¨ `SetXXX()` æ¹æ³ - è¿äºæ¹æ³ä¼è°ç¨ææå½æ°ï¼å¹¶é建空ç Object æ Array: + + ~~~~~~~~~~cpp + Document d; + ... + d.SetObject(); // clear and minimize + ~~~~~~~~~~ + + å¦å¤ï¼ä¹å¯ä»¥åèå¨ [C++ swap with temporary idiom](https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Clear-and-minimize) ä¸çä¸ç§çä»·çæ¹æ³: + ~~~~~~~~~~cpp + Value(kObjectType).Swap(d); + ~~~~~~~~~~ + æè ï¼ä½¿ç¨è¿ä¸ªç¨å¾®é¿ä¸ç¹ç代ç ä¹è½å®æåæ ·çäºæ : + ~~~~~~~~~~cpp + d.Swap(Value(kObjectType).Move()); + ~~~~~~~~~~ + +9. å¦ä½å°ä¸ä¸ª `document` èç¹æå ¥å°å¦ä¸ä¸ª `document` ä¸ï¼ + + æ¯å¦æ以ä¸ä¸¤ä¸ª document(DOM): + ~~~~~~~~~~cpp + Document person; + person.Parse("{\"person\":{\"name\":{\"first\":\"Adam\",\"last\":\"Thomas\"}}}"); + + Document address; + address.Parse("{\"address\":{\"city\":\"Moscow\",\"street\":\"Quiet\"}}"); + ~~~~~~~~~~ + å设æ们å¸æå°æ´ä¸ª `address` æå ¥å° `person` ä¸ï¼ä½ä¸ºå ¶çä¸ä¸ªåèç¹: + ~~~~~~~~~~js + { "person": { + "name": { "first": "Adam", "last": "Thomas" }, + "address": { "city": "Moscow", "street": "Quiet" } + } + } + ~~~~~~~~~~ + + å¨æå ¥èç¹çè¿ç¨ä¸éè¦æ³¨æ `document` å `value` ççå½å¨æ并ä¸æ£ç¡®å°ä½¿ç¨ allocator è¿è¡å ååé å管çã + + ä¸ä¸ªç®åææçæ¹æ³å°±æ¯ä¿®æ¹ä¸è¿° `address` åéçå®ä¹ï¼è®©å ¶ä½¿ç¨ `person` ç allocator åå§åï¼ç¶åå°å ¶æ·»å å°æ ¹èç¹ã + + ~~~~~~~~~~cpp + Documnet address(person.GetAllocator()); + ... + person["person"].AddMember("address", address["address"], person.GetAllocator()); + ~~~~~~~~~~ + å½ç¶ï¼å¦æä½ ä¸æ³éè¿æ¾å¼å°ååº `address` ç key æ¥å¾å°å ¶å¼ï¼å¯ä»¥ä½¿ç¨è¿ä»£å¨æ¥å®ç°: + ~~~~~~~~~~cpp + auto addressRoot = address.MemberBegin(); + person["person"].AddMember(addressRoot->name, addressRoot->value, person.GetAllocator()); + ~~~~~~~~~~ + + æ¤å¤ï¼è¿å¯ä»¥éè¿æ·±æ·è´ address document æ¥å®ç°: + ~~~~~~~~~~cpp + Value addressValue = Value(address["address"], person.GetAllocator()); + person["person"].AddMember("address", addressValue, person.GetAllocator()); + ~~~~~~~~~~ + +## Document/Value (DOM) + +1. ä»ä¹æ¯è½¬ç§»è¯æï¼ä¸ºä»ä¹ï¼ + + `Value` ä¸ç¨å¤å¶è¯æï¼è使ç¨äºè½¬ç§»è¯æãè¿æ¯æï¼å½ææ¥æºå¼èµå¼äºç®æ å¼æ¶ï¼æ¥æºå¼çæææä¼è½¬ç§»è³ç®æ å¼ã + + ç±äºè½¬ç§»å¿«äºå¤å¶ï¼æ¤è®¾è®¡å³å®å¼ºè¿«ä½¿ç¨è 注æå°å¤å¶çæ¶èã + +2. ææ ·å»å¤å¶ä¸ä¸ªå¼ï¼ + + æ两个 API å¯ç¨ï¼å« allocator çæé å½æ°ï¼ä»¥å `CopyFrom()`ãå¯åè [æ·±å¤å¶ Value](doc/tutorial.zh-cn.md) éçç¨ä¾ã + +3. 为ä»ä¹æéè¦æä¾å符串çé¿åº¦ï¼ + + ç±äº C å符串æ¯ç©ºå符ç»å°¾çï¼éè¦ä½¿ç¨ `strlen()` å»è®¡ç®å ¶é¿åº¦ï¼è¿æ¯çº¿æ§å¤æ度çæä½ãè¥ä½¿ç¨è å·²ç¥å符串çé¿åº¦ï¼å¯¹å¾å¤æä½æ¥è¯´ä¼é æä¸å¿ è¦çæ¶èã + + æ¤å¤ï¼RapidJSON å¯å¤çå«æ `\u0000`ï¼ç©ºå符ï¼çå符串ãè¥ä¸ä¸ªå符串å«æ空å符ï¼`strlen()` 便ä¸è½è¿åçæ£çå符串é¿åº¦ãå¨è¿ç§æ åµä¸ä½¿ç¨è å¿ é¡»æç¡®å°æä¾å符串é¿åº¦ã + +4. 为ä»ä¹å¨è®¸å¤ DOM æä½ API ä¸è¦æä¾åé å¨ä½ä¸ºåæ°ï¼ + + ç±äºè¿äº API æ¯ `Value` çæåå½æ°ï¼æ们ä¸å¸æ为æ¯ä¸ª `Value` å¨åä¸ä¸ªåé å¨æéã + +5. å®ä¼è½¬æ¢åç§æ°å¼ç±»åä¹ï¼ + + å½ä½¿ç¨ `GetInt()`ã`GetUint()` ç API æ¶ï¼å¯è½ä¼åç转æ¢ã对äºæ´æ°è³æ´æ°è½¬æ¢ï¼ä» å½ä¿è¯è½¬æ¢å®å ¨æä¼è½¬æ¢ï¼å¦åä¼æè¨å¤±è´¥ï¼ãç¶èï¼å½æä¸ä¸ª 64 ä½æå·ï¼æ å·æ´æ°è½¬æ¢è³ double æ¶ï¼å®ä¼è½¬æ¢ï¼ä½æå¯è½ä¼æ失精度ãå«æå°æ°çæ°åãæå¤§äº 64 ä½çæ´æ°ï¼é½åªè½ä½¿ç¨ `GetDouble()` è·åå ¶å¼ã + +## Reader/Writer (SAX) + +1. 为ä»ä¹ä¸ä» ä» ç¨ `printf` è¾åºä¸ä¸ª JSONï¼ä¸ºä»ä¹éè¦ `Writer`ï¼ + + æéè¦çæ¯ï¼`Writer` è½ç¡®ä¿è¾åºç JSON æ¯æ ¼å¼æ£ç¡®çãé误å°è°ç¨ SAX äºä»¶ï¼å¦ `StartObject()` éé `EndArray()`ï¼ä¼é ææè¨å¤±è´¥ãæ¤å¤ï¼`Writer` ä¼æå符串è¿è¡è½¬ä¹ï¼å¦ `\n`ï¼ãæåï¼`printf()` çæ°å¼è¾åºå¯è½å¹¶ä¸æ¯ä¸ä¸ªåæ³ç JSON numberï¼ç¹å«æ¯æäº locale ä¼ææ°ååé符ãèä¸ `Writer` çæ°å¼å符串转æ¢æ¯ä½¿ç¨é常快çç®æ³æ¥å®ç°çï¼èè¿ `printf()` å `iostream`ã + +2. æè½å¦æå解æè¿ç¨ï¼å¹¶å¨ç¨å继ç»ï¼ + + åºäºæ§è½èèï¼ç®åçæ¬å¹¶ä¸ç´æ¥æ¯ææ¤åè½ãç¶èï¼è¥æ§è¡ç¯å¢æ¯æå¤çº¿ç¨ï¼ä½¿ç¨è å¯ä»¥å¨å¦ä¸çº¿ç¨è§£æ JSONï¼å¹¶éè¿é»å¡è¾å ¥æµå»æåã + +## Unicode + +1. å®æ¯å¦æ¯æ UTF-8ãUTF-16 åå ¶ä»æ ¼å¼ï¼ + + æ¯ãå®å®å ¨æ¯æ UTF-8ãUTF-16ï¼å¤§ç«¯ï¼å°ç«¯ï¼ãUTF-32ï¼å¤§ç«¯ï¼å°ç«¯ï¼å ASCIIã + +2. å®è½å¦æ£æµç¼ç çåæ³æ§ï¼ + + è½ãåªéæ `kParseValidateEncodingFlag` åèä¼ ç» `Parse()`ãè¥åç°å¨è¾å ¥æµä¸æéæ³çç¼ç ï¼å®å°±ä¼äº§ç `kParseErrorStringInvalidEncoding` é误ã + +3. ä»ä¹æ¯ä»£ç对ï¼surrogate pair)ï¼RapidJSON æ¯å¦æ¯æï¼ + + JSON ä½¿ç¨ UTF-16 ç¼ç å»è½¬ä¹ Unicode å符ï¼ä¾å¦ `\u5927` 表示ä¸æåâ大âãè¦å¤çåºæ¬å¤æç§å¹³é¢ï¼basic multilingual planeï¼BMPï¼ä»¥å¤çå符æ¶ï¼UTF-16 ä¼æé£äºå符ç¼ç æ两个 16 ä½å¼ï¼è¿ç§°ä¸º UTF-16 代ç对ãä¾å¦ï¼ç»æåå符 U+1F602 å¨ JSON ä¸å¯è¢«ç¼ç æ `\uD83D\uDE02`ã + + RapidJSON å®å ¨æ¯æ解æåçæ UTF-16 代ç对ã + +4. å®è½å¦å¤ç JSON å符串ä¸ç `\u0000`ï¼ç©ºå符ï¼ï¼ + + è½ãRapidJSON å®å ¨æ¯æ JSON å符串ä¸ç空å符ãç¶èï¼ä½¿ç¨è éè¦æ³¨æå°è¿ä»¶äºï¼å¹¶ä½¿ç¨ `GetStringLength()` åç¸å ³ API å»åå¾å符串çæ£é¿åº¦ã + +5. è½å¦å¯¹ææé ASCII å符è¾åºæ `\uxxxx` å½¢å¼ï¼ + + å¯ä»¥ãåªè¦å¨ `Writer` ä¸ä½¿ç¨ `ASCII<>` ä½ä¸ºè¾åºç¼ç åæ°ï¼å°±å¯ä»¥å¼ºé¼è½¬ä¹é£äºå符ã + +## æµ + +1. ææä¸ä¸ªå¾å¤§ç JSON æ件ãæåºå¦æå®æ´ä¸ªè½½å ¥å åä¸ï¼ + + 使ç¨è å¯ä½¿ç¨ `FileReadStream` å»éåè¯»å ¥æ件ãä½è¥ä½¿ç¨äºåä½è§£æï¼å¿ é¡»è½½å ¥æ´ä¸ªæ件ã + +2. æè½å¦è§£æä¸ä¸ªä»ç½ç»ä¸ä¸²æµè¿æ¥ç JSONï¼ + + å¯ä»¥ã使ç¨è å¯æ ¹æ® `FileReadStream` çå®ç°ï¼å»å®ç°ä¸ä¸ªèªå®ä¹çæµã + +3. æä¸ç¥éä¸äº JSON å°ä¼ä½¿ç¨åªç§ç¼ç ãææ ·å¤çå®ä»¬ï¼ + + ä½ å¯ä»¥ä½¿ç¨ `AutoUTFInputStream`ï¼å®è½èªå¨æ£æµè¾å ¥æµçç¼ç ãç¶èï¼å®ä¼å¸¦æ¥ä¸äºæ§è½å¼éã + +4. ä»ä¹æ¯ BOMï¼RapidJSON ææ ·å¤çå®ï¼ + + [åè顺åºæ è®°ï¼byte order mark, BOMï¼](http://en.wikipedia.org/wiki/Byte_order_mark) ææ¶ä¼åºç°äºæ件ï¼æµçå¼å§ï¼ä»¥è¡¨ç¤ºå ¶ UTF ç¼ç ç±»åã + + RapidJSON ç `EncodedInputStream` å¯æ£æµï¼è·³è¿ BOMã`EncodedOutputStream` å¯éæ©æ¯å¦åå ¥ BOMãå¯åè [ç¼ç æµ](doc/stream.zh-cn.md) ä¸çä¾åã + +5. 为ä»ä¹ä¼æ¶å大端ï¼å°ç«¯ï¼ + + æµç大端ï¼å°ç«¯æ¯ UTF-16 å UTF-32 æµè¦å¤ççé®é¢ï¼è UTF-8 ä¸éè¦å¤çã + +## æ§è½ + +1. RapidJSON æ¯å¦ççå¿«ï¼ + + æ¯ãå®å¯è½æ¯æå¿«çå¼æº JSON åºãæä¸ä¸ª [è¯æµ](https://github.com/miloyip/nativejson-benchmark) è¯ä¼° C/C++ JSON åºçæ§è½ã + +2. 为ä»ä¹å®ä¼å¿«ï¼ + + RapidJSON ç许å¤è®¾è®¡æ¯é对æ¶é´ï¼ç©ºé´æ§è½æ¥è®¾è®¡çï¼è¿äºå³å®å¯è½ä¼å½±å API çæç¨æ§ãæ¤å¤ï¼å®ä¹ä½¿ç¨äºè®¸å¤åºå±ä¼åï¼å é¨å½æ°ï¼intrinsicãSIMDï¼åç¹å«çç®æ³ï¼èªå®ä¹ç double è³å符串转æ¢ãåç¬¦ä¸²è³ double ç转æ¢ï¼ã + +3. ä»æ¯æ¯ SIMDï¼å®å¦ä½ç¨äº RapidJSONï¼ + + [SIMD](http://en.wikipedia.org/wiki/SIMD) æ令å¯ä»¥å¨ç°ä»£ CPU ä¸æ§è¡å¹¶è¡è¿ç®ãRapidJSON æ¯æäº Intel ç SSE2/SSE4.2 å»å éè·³è¿ç©ºç½å符ãå¨è§£æå«ç¼©è¿ç JSON æ¶ï¼è¿è½æåæ§è½ãåªè¦å®ä¹å为 `RAPIDJSON_SSE2` æ `RAPIDJSON_SSE42` çå®ï¼å°±è½å¯å¨è¿ä¸ªåè½ãç¶èï¼è¥å¨ä¸æ¯æè¿äºæ令éçæºå¨ä¸æ§è¡è¿äºå¯æ§è¡æ件ï¼ä¼å¯¼è´å´©æºã + +4. å®ä¼æ¶è许å¤å åä¹ï¼ + + RapidJSON ç设计ç®æ æ¯åä½å åå ç¨ã + + å¨ SAX API ä¸ï¼`Reader` æ¶èçå åä¸ JSON æ 深度å ä¸æé¿ JSON å符ææ£æ¯ã + + å¨ DOM API ä¸ï¼æ¯ä¸ª `Value` å¨ 32/64 ä½æ¶æä¸åå«æ¶è 16/24 åèãRapidJSON ä¹ä½¿ç¨ä¸ä¸ªç¹æ®çå ååé å¨å»åå°åé çé¢å¤å¼éã + +5. é«æ§è½çæä¹ä½å¨ï¼ + + æäºåºç¨ç¨åºéè¦å¤çé常大ç JSON æ件ãèæäºåå°åºç¨ç¨åºéè¦å¤ç大éç JSONãè¾¾å°é«æ§è½åæ¶æ¹å延æ¶åååéãæ´å¹¿ä¹æ¥è¯´ï¼è¿ä¹å¯ä»¥èçè½æºã + +## å «æ + +1. è°æ¯ RapidJSON çå¼åè ï¼ + + å¶å²å³°ï¼Milo Yipï¼[miloyip](https://github.com/miloyip)ï¼æ¯ RapidJSON çåä½è ãå ¨ä¸ç许å¤è´¡ç®è ä¸ç´å¨æ¹å RapidJSONãPhilipp A. Hartmannï¼[pah](https://github.com/pah)ï¼å®ç°äºè®¸å¤æ¹è¿ï¼ä¹è®¾ç½®äºèªå¨åæµè¯ï¼èä¸è¿åä¸è®¸å¤ç¤¾åºè®¨è®ºãä¸æ¬§åï¼Don Dingï¼[thebusytypist](https://github.com/thebusytypist)ï¼å®ç°äºè¿ä»£å¼è§£æå¨ãAndrii Senkovychï¼[jollyroger](https://github.com/jollyroger)ï¼å®æäºå CMake çè¿ç§»ãKostaï¼[Kosta-Github](https://github.com/Kosta-Github)ï¼æä¾äºä¸ä¸ªé常çµå·§ççå符串ä¼åãä¹éè¦æè°¢å ¶ä»ç®è å社åºæåã + +2. 为ä½ä½ è¦å¼å RapidJSONï¼ + + å¨ 2011 å¹´å¼å§è¿é¡¹ç®æ¯ï¼å®ä» ä¸ä¸ªå ´è¶£é¡¹ç®ãMilo Yip æ¯ä¸ä¸ªæ¸¸æç¨åºåï¼ä»å¨é£æ¶å认è¯å° JSON 并å¸æå¨æªæ¥ç项ç®ä¸ä½¿ç¨ãç±äº JSON 好åå¾ç®åï¼ä»å¸æåä¸ä¸ªä» æ头æ件并ä¸å¿«éçç¨åºåºã + +3. 为ä»ä¹å¼åä¸æ®µæä¸æ®µé¿æç©ºæ¡£ï¼ + + 主è¦æ¯ä¸ªäººå ç´ ï¼ä¾å¦å å ¥æ°å®¶åºæåãå¦å¤ï¼Milo Yip ä¹è±äºè®¸å¤ä¸é¦æ¶é´å»ç¿»è¯ Jason Gregory çãGame Engine Architectureãè³ä¸æçã游æå¼ææ¶æãã + +4. 为ä»ä¹è¿ä¸ªé¡¹ç®ä» Google Code æ¬å° GitHubï¼ + + è¿æ¯å¤§å¿æè¶ï¼èä¸ GitHub æ´ä¸ºå¼ºå¤§åæ¹ä¾¿ã
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/features.md ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/features.md b/thirdparty/rapidjson-1.1.0/doc/features.md new file mode 100644 index 0000000..732fb21 --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/features.md @@ -0,0 +1,104 @@ +# Features + +## General + +* Cross-platform + * Compilers: Visual Studio, gcc, clang, etc. + * Architectures: x86, x64, ARM, etc. + * Operating systems: Windows, Mac OS X, Linux, iOS, Android, etc. +* Easy installation + * Header files only library. Just copy the headers to your project. +* Self-contained, minimal dependences + * No STL, BOOST, etc. + * Only included `<cstdio>`, `<cstdlib>`, `<cstring>`, `<inttypes.h>`, `<new>`, `<stdint.h>`. +* Without C++ exception, RTTI +* High performance + * Use template and inline functions to reduce function call overheads. + * Internal optimized Grisu2 and floating point parsing implementations. + * Optional SSE2/SSE4.2 support. + +## Standard compliance + +* RapidJSON should be fully RFC4627/ECMA-404 compliance. +* Support JSON Pointer (RFC6901). +* Support JSON Schema Draft v4. +* Support Unicode surrogate. +* Support null character (`"\u0000"`) + * For example, `["Hello\u0000World"]` can be parsed and handled gracefully. There is API for getting/setting lengths of string. +* Support optional relaxed syntax. + * Single line (`// ...`) and multiple line (`/* ... */`) comments (`kParseCommentsFlag`). + * Trailing commas at the end of objects and arrays (`kParseTrailingCommasFlag`). + * `NaN`, `Inf`, `Infinity`, `-Inf` and `-Infinity` as `double` values (`kParseNanAndInfFlag`) +* [NPM compliant](http://github.com/miloyip/rapidjson/blob/master/doc/npm.md). + +## Unicode + +* Support UTF-8, UTF-16, UTF-32 encodings, including little endian and big endian. + * These encodings are used in input/output streams and in-memory representation. +* Support automatic detection of encodings in input stream. +* Support transcoding between encodings internally. + * For example, you can read a UTF-8 file and let RapidJSON transcode the JSON strings into UTF-16 in the DOM. +* Support encoding validation internally. + * For example, you can read a UTF-8 file, and let RapidJSON check whether all JSON strings are valid UTF-8 byte sequence. +* Support custom character types. + * By default the character types are `char` for UTF8, `wchar_t` for UTF16, `uint32_t` for UTF32. +* Support custom encodings. + +## API styles + +* SAX (Simple API for XML) style API + * Similar to [SAX](http://en.wikipedia.org/wiki/Simple_API_for_XML), RapidJSON provides a event sequential access parser API (`rapidjson::GenericReader`). It also provides a generator API (`rapidjson::Writer`) which consumes the same set of events. +* DOM (Document Object Model) style API + * Similar to [DOM](http://en.wikipedia.org/wiki/Document_Object_Model) for HTML/XML, RapidJSON can parse JSON into a DOM representation (`rapidjson::GenericDocument`), for easy manipulation, and finally stringify back to JSON if needed. + * The DOM style API (`rapidjson::GenericDocument`) is actually implemented with SAX style API (`rapidjson::GenericReader`). SAX is faster but sometimes DOM is easier. Users can pick their choices according to scenarios. + +## Parsing + +* Recursive (default) and iterative parser + * Recursive parser is faster but prone to stack overflow in extreme cases. + * Iterative parser use custom stack to keep parsing state. +* Support *in situ* parsing. + * Parse JSON string values in-place at the source JSON, and then the DOM points to addresses of those strings. + * Faster than convention parsing: no allocation for strings, no copy (if string does not contain escapes), cache-friendly. +* Support 32-bit/64-bit signed/unsigned integer and `double` for JSON number type. +* Support parsing multiple JSONs in input stream (`kParseStopWhenDoneFlag`). +* Error Handling + * Support comprehensive error code if parsing failed. + * Support error message localization. + +## DOM (Document) + +* RapidJSON checks range of numerical values for conversions. +* Optimization for string literal + * Only store pointer instead of copying +* Optimization for "short" strings + * Store short string in `Value` internally without additional allocation. + * For UTF-8 string: maximum 11 characters in 32-bit, 21 characters in 64-bit (13 characters in x86-64). +* Optionally support `std::string` (define `RAPIDJSON_HAS_STDSTRING=1`) + +## Generation + +* Support `rapidjson::PrettyWriter` for adding newlines and indentations. + +## Stream + +* Support `rapidjson::GenericStringBuffer` for storing the output JSON as string. +* Support `rapidjson::FileReadStream` and `rapidjson::FileWriteStream` for input/output `FILE` object. +* Support custom streams. + +## Memory + +* Minimize memory overheads for DOM. + * Each JSON value occupies exactly 16/20 bytes for most 32/64-bit machines (excluding text string). +* Support fast default allocator. + * A stack-based allocator (allocate sequentially, prohibit to free individual allocations, suitable for parsing). + * User can provide a pre-allocated buffer. (Possible to parse a number of JSONs without any CRT allocation) +* Support standard CRT(C-runtime) allocator. +* Support custom allocators. + +## Miscellaneous + +* Some C++11 support (optional) + * Rvalue reference + * `noexcept` specifier + * Range-based for loop http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/features.zh-cn.md ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/features.zh-cn.md b/thirdparty/rapidjson-1.1.0/doc/features.zh-cn.md new file mode 100644 index 0000000..fd3fd4d --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/features.zh-cn.md @@ -0,0 +1,103 @@ +# ç¹ç¹ + +## æ»ä½ + +* è·¨å¹³å° + * ç¼è¯å¨ï¼Visual Studioãgccãclang ç + * æ¶æï¼x86ãx64ãARM ç + * æä½ç³»ç»ï¼WindowsãMac OS XãLinuxãiOSãAndroid ç +* 容æå®è£ + * åªæ头æ件çåºãåªéæ头æ件å¤å¶è³ä½ ç项ç®ä¸ã +* ç¬ç«ãæå°ä¾èµ + * ä¸éä¾èµ STLãBOOST çã + * åªå å« `<cstdio>`, `<cstdlib>`, `<cstring>`, `<inttypes.h>`, `<new>`, `<stdint.h>`ã +* æ²¡ä½¿ç¨ C++ å¼å¸¸ãRTTI +* é«æ§è½ + * 使ç¨æ¨¡çåå èå½æ°å»éä½å½æ°è°ç¨å¼éã + * å é¨ç»ä¼åç Grisu2 åæµ®ç¹æ°è§£æå®ç°ã + * å¯éç SSE2/SSE4.2 æ¯æã + +## 符åæ å + +* RapidJSON åºå®å ¨ç¬¦å RFC4627/ECMA-404 æ åã +* æ¯æ JSON Pointer (RFC6901). +* æ¯æ JSON Schema Draft v4. +* æ¯æ Unicod 代ç对ï¼surrogate pairï¼ã +* æ¯æ空å符ï¼`"\u0000"`ï¼ã + * ä¾å¦ï¼å¯ä»¥ä¼é å°è§£æåå¤ç `["Hello\u0000World"]`ãå«è¯»åå符串é¿åº¦ç APIã +* æ¯æå¯éçæ¾å®½è¯æ³ + * åè¡ï¼`// ...`ï¼åå¤è¡ï¼`/* ... */`ï¼ æ³¨é (`kParseCommentsFlag`)ã + * å¨å¯¹è±¡åæ°ç»ç»æåå«éå· (`kParseTrailingCommasFlag`)ã + * `NaN`ã`Inf`ã`Infinity`ã`-Inf` å `-Infinity` ä½ä¸º `double` å¼ (`kParseNanAndInfFlag`) +* [NPM å ¼å®¹](https://github.com/miloyip/rapidjson/blob/master/doc/npm.md). + +## Unicode + +* æ¯æ UTF-8ãUTF-16ãUTF-32 ç¼ç ï¼å æ¬å°ç«¯åºå大端åºã + * è¿äºç¼ç ç¨äºè¾å ¥è¾åºæµï¼ä»¥åå åä¸ç表示ã +* æ¯æä»è¾å ¥æµèªå¨æ£æµç¼ç ã +* å é¨æ¯æç¼ç ç转æ¢ã + * ä¾å¦ï¼ä½ å¯ä»¥è¯»åä¸ä¸ª UTF-8 æ件ï¼è®© RapidJSON æ JSON å符串转æ¢è³ UTF-16 ç DOMã +* å é¨æ¯æç¼ç æ ¡éªã + * ä¾å¦ï¼ä½ å¯ä»¥è¯»åä¸ä¸ª UTF-8 æ件ï¼è®© RapidJSON æ£æ¥æ¯å¦ææ JSON å符串æ¯åæ³ç UTF-8 åèåºåã +* æ¯æèªå®ä¹çå符类åã + * é¢è®¾çå符类åæ¯ï¼UTF-8 为 `char`ï¼UTF-16 为 `wchar_t`ï¼UTF32 为 `uint32_t`ã +* æ¯æèªå®ä¹çç¼ç ã + +## API é£æ ¼ + +* SAXï¼Simple API for XMLï¼é£æ ¼ API + * ç±»ä¼¼äº [SAX](http://en.wikipedia.org/wiki/Simple_API_for_XML), RapidJSON æä¾ä¸ä¸ªäºä»¶å¾ªåºè®¿é®ç解æå¨ APIï¼`rapidjson::GenericReader`ï¼ãRapidJSON ä¹æä¾ä¸ä¸ªçæå¨ APIï¼`rapidjson::Writer`ï¼ï¼å¯ä»¥å¤çç¸åçäºä»¶éåã +* DOMï¼Document Object Modelï¼é£æ ¼ API + * ç±»ä¼¼äº HTMLï¼XML ç [DOM](http://en.wikipedia.org/wiki/Document_Object_Model)ï¼RapidJSON å¯æ JSON 解æè³ä¸ä¸ª DOM 表示æ¹å¼ï¼`rapidjson::GenericDocument`ï¼ï¼ä»¥æ¹ä¾¿æä½ãå¦æéè¦ï¼å¯æ DOM 转æ¢ï¼stringifyï¼å JSONã + * DOM é£æ ¼ APIï¼`rapidjson::GenericDocument`ï¼å®é ä¸æ¯ç± SAX é£æ ¼ APIï¼`rapidjson::GenericReader`ï¼å®ç°çãSAX æ´å¿«ï¼ä½ææ¶ DOM æ´æç¨ãç¨æ·å¯æ ¹æ®æ åµä½åºéæ©ã + +## 解æ + +* éå½å¼ï¼é¢è®¾ï¼åè¿ä»£å¼è§£æå¨ + * éå½å¼è§£æå¨è¾å¿«ï¼ä½å¨æ端æ åµä¸å¯åºç°å æ 溢åºã + * è¿ä»£å¼è§£æå¨ä½¿ç¨èªå®ä¹çå æ å»ç»´æ解æç¶æã +* æ¯æåä½ï¼*in situ*ï¼è§£æã + * æ JSON å符串çå¼è§£æè³å JSON ä¹ä¸ï¼ç¶å让 DOM æåé£äºå符串ã + * æ¯å¸¸è§åææ´å¿«ï¼ä¸éå符串çå ååé ãä¸éå¤å¶ï¼å¦å符串ä¸å«è½¬ä¹ç¬¦ï¼ãç¼åå好ã +* å¯¹äº JSON æ°åç±»åï¼æ¯æ 32-bit/64-bit çæå·ï¼æ å·æ´æ°ï¼ä»¥å `double`ã +* é误å¤ç + * æ¯æ详尽ç解æé误代å·ã + * æ¯ææ¬å°åé误信æ¯ã + +## DOM (Document) + +* RapidJSON å¨ç±»å转æ¢æ¶ä¼æ£æ¥æ°å¼çèå´ã +* å符串åé¢éçä¼å + * åªå¨åæéï¼ä¸ä½å¤å¶ +* ä¼åâçâå符串 + * å¨ `Value` å å¨åçå符串ï¼æ éé¢å¤åé ã + * 对 UTF-8 å符串æ¥è¯´ï¼32 ä½æ¶æä¸å¯åå¨æå¤ 11 å符ï¼64 ä½ä¸ 21 å符ï¼x86-64 ä¸ 13 å符ï¼ã +* å¯éå°æ¯æ `std::string`ï¼å®ä¹ `RAPIDJSON_HAS_STDSTRING=1`ï¼ + +## çæ + +* æ¯æ `rapidjson::PrettyWriter` å»å å ¥æ¢è¡å缩è¿ã + +## è¾å ¥è¾åºæµ + +* æ¯æ `rapidjson::GenericStringBuffer`ï¼æè¾åºç JSON å¨åäºå符串å ã +* æ¯æ `rapidjson::FileReadStream` å `rapidjson::FileWriteStream`ï¼ä½¿ç¨ `FILE` 对象ä½è¾å ¥è¾åºã +* æ¯æèªå®ä¹è¾å ¥è¾åºæµã + +## å å + +* æå°å DOM çå åå¼éã + * 对大é¨å 32ï¼64 ä½æºå¨èè¨ï¼æ¯ä¸ª JSON å¼åªå 16 æ 20 åèï¼ä¸å å«å符串ï¼ã +* æ¯æå¿«éçé¢è®¾åé å¨ã + * å®æ¯ä¸ä¸ªå æ å½¢å¼çåé å¨ï¼é¡ºåºåé ï¼ä¸å®¹è®¸åç¬éæ¾ï¼éå解æè¿ç¨ä¹ç¨ï¼ã + * 使ç¨è ä¹å¯æä¾ä¸ä¸ªé¢åé çç¼å²åºãï¼æå¯è½è¾¾è³æ é CRT åé å°±è½è§£æå¤ä¸ª JSONï¼ +* æ¯ææ å CRTï¼C-runtimeï¼åé å¨ã +* æ¯æèªå®ä¹åé å¨ã + +## å ¶ä» + +* ä¸äº C++11 çæ¯æï¼å¯éï¼ + * å³å¼å¼ç¨ï¼rvalue referenceï¼ + * `noexcept` 修饰符 + * èå´ for å¾ªç¯ http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/internals.md ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/internals.md b/thirdparty/rapidjson-1.1.0/doc/internals.md new file mode 100644 index 0000000..49802a0 --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/internals.md @@ -0,0 +1,365 @@ +# Internals + +This section records some design and implementation details. + +[TOC] + +# Architecture {#Architecture} + +## SAX and DOM + +The basic relationships of SAX and DOM is shown in the following UML diagram. + +![Architecture UML class diagram](diagram/architecture.png) + +The core of the relationship is the `Handler` concept. From the SAX side, `Reader` parses a JSON from a stream and publish events to a `Handler`. `Writer` implements the `Handler` concept to handle the same set of events. From the DOM side, `Document` implements the `Handler` concept to build a DOM according to the events. `Value` supports a `Value::Accept(Handler&)` function, which traverses the DOM to publish events. + +With this design, SAX is not dependent on DOM. Even `Reader` and `Writer` have no dependencies between them. This provides flexibility to chain event publisher and handlers. Besides, `Value` does not depends on SAX as well. So, in addition to stringify a DOM to JSON, user may also stringify it to a XML writer, or do anything else. + +## Utility Classes + +Both SAX and DOM APIs depends on 3 additional concepts: `Allocator`, `Encoding` and `Stream`. Their inheritance hierarchy is shown as below. + +![Utility classes UML class diagram](diagram/utilityclass.png) + +# Value {#Value} + +`Value` (actually a typedef of `GenericValue<UTF8<>>`) is the core of DOM API. This section describes the design of it. + +## Data Layout {#DataLayout} + +`Value` is a [variant type](http://en.wikipedia.org/wiki/Variant_type). In RapidJSON's context, an instance of `Value` can contain 1 of 6 JSON value types. This is possible by using `union`. Each `Value` contains two members: `union Data data_` and a`unsigned flags_`. The `flags_` indiciates the JSON type, and also additional information. + +The following tables show the data layout of each type. The 32-bit/64-bit columns indicates the size of the field in bytes. + +| Null | |32-bit|64-bit| +|-------------------|----------------------------------|:----:|:----:| +| (unused) | |4 |8 | +| (unused) | |4 |4 | +| (unused) | |4 |4 | +| `unsigned flags_` | `kNullType kNullFlag` |4 |4 | + +| Bool | |32-bit|64-bit| +|-------------------|----------------------------------------------------|:----:|:----:| +| (unused) | |4 |8 | +| (unused) | |4 |4 | +| (unused) | |4 |4 | +| `unsigned flags_` | `kBoolType` (either `kTrueFlag` or `kFalseFlag`) |4 |4 | + +| String | |32-bit|64-bit| +|---------------------|-------------------------------------|:----:|:----:| +| `Ch* str` | Pointer to the string (may own) |4 |8 | +| `SizeType length` | Length of string |4 |4 | +| (unused) | |4 |4 | +| `unsigned flags_` | `kStringType kStringFlag ...` |4 |4 | + +| Object | |32-bit|64-bit| +|---------------------|-------------------------------------|:----:|:----:| +| `Member* members` | Pointer to array of members (owned) |4 |8 | +| `SizeType size` | Number of members |4 |4 | +| `SizeType capacity` | Capacity of members |4 |4 | +| `unsigned flags_` | `kObjectType kObjectFlag` |4 |4 | + +| Array | |32-bit|64-bit| +|---------------------|-------------------------------------|:----:|:----:| +| `Value* values` | Pointer to array of values (owned) |4 |8 | +| `SizeType size` | Number of values |4 |4 | +| `SizeType capacity` | Capacity of values |4 |4 | +| `unsigned flags_` | `kArrayType kArrayFlag` |4 |4 | + +| Number (Int) | |32-bit|64-bit| +|---------------------|-------------------------------------|:----:|:----:| +| `int i` | 32-bit signed integer |4 |4 | +| (zero padding) | 0 |4 |4 | +| (unused) | |4 |8 | +| `unsigned flags_` | `kNumberType kNumberFlag kIntFlag kInt64Flag ...` |4 |4 | + +| Number (UInt) | |32-bit|64-bit| +|---------------------|-------------------------------------|:----:|:----:| +| `unsigned u` | 32-bit unsigned integer |4 |4 | +| (zero padding) | 0 |4 |4 | +| (unused) | |4 |8 | +| `unsigned flags_` | `kNumberType kNumberFlag kUIntFlag kUInt64Flag ...` |4 |4 | + +| Number (Int64) | |32-bit|64-bit| +|---------------------|-------------------------------------|:----:|:----:| +| `int64_t i64` | 64-bit signed integer |8 |8 | +| (unused) | |4 |8 | +| `unsigned flags_` | `kNumberType kNumberFlag kInt64Flag ...` |4 |4 | + +| Number (Uint64) | |32-bit|64-bit| +|---------------------|-------------------------------------|:----:|:----:| +| `uint64_t i64` | 64-bit unsigned integer |8 |8 | +| (unused) | |4 |8 | +| `unsigned flags_` | `kNumberType kNumberFlag kInt64Flag ...` |4 |4 | + +| Number (Double) | |32-bit|64-bit| +|---------------------|-------------------------------------|:----:|:----:| +| `uint64_t i64` | Double precision floating-point |8 |8 | +| (unused) | |4 |8 | +| `unsigned flags_` | `kNumberType kNumberFlag kDoubleFlag` |4 |4 | + +Here are some notes: +* To reduce memory consumption for 64-bit architecture, `SizeType` is typedef as `unsigned` instead of `size_t`. +* Zero padding for 32-bit number may be placed after or before the actual type, according to the endianess. This makes possible for interpreting a 32-bit integer as a 64-bit integer, without any conversion. +* An `Int` is always an `Int64`, but the converse is not always true. + +## Flags {#Flags} + +The 32-bit `flags_` contains both JSON type and other additional information. As shown in the above tables, each JSON type contains redundant `kXXXType` and `kXXXFlag`. This design is for optimizing the operation of testing bit-flags (`IsNumber()`) and obtaining a sequential number for each type (`GetType()`). + +String has two optional flags. `kCopyFlag` means that the string owns a copy of the string. `kInlineStrFlag` means using [Short-String Optimization](#ShortString). + +Number is a bit more complicated. For normal integer values, it can contains `kIntFlag`, `kUintFlag`, `kInt64Flag` and/or `kUint64Flag`, according to the range of the integer. For numbers with fraction, and integers larger than 64-bit range, they will be stored as `double` with `kDoubleFlag`. + +## Short-String Optimization {#ShortString} + + [Kosta](https://github.com/Kosta-Github) provided a very neat short-string optimization. The optimization idea is given as follow. Excluding the `flags_`, a `Value` has 12 or 16 bytes (32-bit or 64-bit) for storing actual data. Instead of storing a pointer to a string, it is possible to store short strings in these space internally. For encoding with 1-byte character type (e.g. `char`), it can store maximum 11 or 15 characters string inside the `Value` type. + +| ShortString (Ch=char) | |32-bit|64-bit| +|---------------------|-------------------------------------|:----:|:----:| +| `Ch str[MaxChars]` | String buffer |11 |15 | +| `Ch invLength` | MaxChars - Length |1 |1 | +| `unsigned flags_` | `kStringType kStringFlag ...` |4 |4 | + +A special technique is applied. Instead of storing the length of string directly, it stores (MaxChars - length). This make it possible to store 11 characters with trailing `\0`. + +This optimization can reduce memory usage for copy-string. It can also improve cache-coherence thus improve runtime performance. + +# Allocator {#InternalAllocator} + +`Allocator` is a concept in RapidJSON: +~~~cpp +concept Allocator { + static const bool kNeedFree; //!< Whether this allocator needs to call Free(). + + // Allocate a memory block. + // \param size of the memory block in bytes. + // \returns pointer to the memory block. + void* Malloc(size_t size); + + // Resize a memory block. + // \param originalPtr The pointer to current memory block. Null pointer is permitted. + // \param originalSize The current size in bytes. (Design issue: since some allocator may not book-keep this, explicitly pass to it can save memory.) + // \param newSize the new size in bytes. + void* Realloc(void* originalPtr, size_t originalSize, size_t newSize); + + // Free a memory block. + // \param pointer to the memory block. Null pointer is permitted. + static void Free(void *ptr); +}; +~~~ + +Note that `Malloc()` and `Realloc()` are member functions but `Free()` is static member function. + +## MemoryPoolAllocator {#MemoryPoolAllocator} + +`MemoryPoolAllocator` is the default allocator for DOM. It allocate but do not free memory. This is suitable for building a DOM tree. + +Internally, it allocates chunks of memory from the base allocator (by default `CrtAllocator`) and stores the chunks as a singly linked list. When user requests an allocation, it allocates memory from the following order: + +1. User supplied buffer if it is available. (See [User Buffer section in DOM](doc/dom.md)) +2. If user supplied buffer is full, use the current memory chunk. +3. If the current block is full, allocate a new block of memory. + +# Parsing Optimization {#ParsingOptimization} + +## Skip Whitespaces with SIMD {#SkipwhitespaceWithSIMD} + +When parsing JSON from a stream, the parser need to skip 4 whitespace characters: + +1. Space (`U+0020`) +2. Character Tabulation (`U+000B`) +3. Line Feed (`U+000A`) +4. Carriage Return (`U+000D`) + +A simple implementation will be simply: +~~~cpp +void SkipWhitespace(InputStream& s) { + while (s.Peek() == ' ' || s.Peek() == '\n' || s.Peek() == '\r' || s.Peek() == '\t') + s.Take(); +} +~~~ + +However, this requires 4 comparisons and a few branching for each character. This was found to be a hot spot. + +To accelerate this process, SIMD was applied to compare 16 characters with 4 white spaces for each iteration. Currently RapidJSON only supports SSE2 and SSE4.2 instructions for this. And it is only activated for UTF-8 memory streams, including string stream or *in situ* parsing. + +To enable this optimization, need to define `RAPIDJSON_SSE2` or `RAPIDJSON_SSE42` before including `rapidjson.h`. Some compilers can detect the setting, as in `perftest.h`: + +~~~cpp +// __SSE2__ and __SSE4_2__ are recognized by gcc, clang, and the Intel compiler. +// We use -march=native with gmake to enable -msse2 and -msse4.2, if supported. +#if defined(__SSE4_2__) +# define RAPIDJSON_SSE42 +#elif defined(__SSE2__) +# define RAPIDJSON_SSE2 +#endif +~~~ + +Note that, these are compile-time settings. Running the executable on a machine without such instruction set support will make it crash. + +### Page boundary issue + +In an early version of RapidJSON, [an issue](https://code.google.com/archive/p/rapidjson/issues/104) reported that the `SkipWhitespace_SIMD()` causes crash very rarely (around 1 in 500,000). After investigation, it is suspected that `_mm_loadu_si128()` accessed bytes after `'\0'`, and across a protected page boundary. + +In [Intel® 64 and IA-32 Architectures Optimization Reference Manual +](http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-optimization-manual.html), section 10.2.1: + +> To support algorithms requiring unaligned 128-bit SIMD memory accesses, memory buffer allocation by a caller function should consider adding some pad space so that a callee function can safely use the address pointer safely with unaligned 128-bit SIMD memory operations. +> The minimal padding size should be the width of the SIMD register that might be used in conjunction with unaligned SIMD memory access. + +This is not feasible as RapidJSON should not enforce such requirement. + +To fix this issue, currently the routine process bytes up to the next aligned address. After tha, use aligned read to perform SIMD processing. Also see [#85](https://github.com/miloyip/rapidjson/issues/85). + +## Local Stream Copy {#LocalStreamCopy} + +During optimization, it is found that some compilers cannot localize some member data access of streams into local variables or registers. Experimental results show that for some stream types, making a copy of the stream and used it in inner-loop can improve performance. For example, the actual (non-SIMD) implementation of `SkipWhitespace()` is implemented as: + +~~~cpp +template<typename InputStream> +void SkipWhitespace(InputStream& is) { + internal::StreamLocalCopy<InputStream> copy(is); + InputStream& s(copy.s); + + while (s.Peek() == ' ' || s.Peek() == '\n' || s.Peek() == '\r' || s.Peek() == '\t') + s.Take(); +} +~~~ + +Depending on the traits of stream, `StreamLocalCopy` will make (or not make) a copy of the stream object, use it locally and copy the states of stream back to the original stream. + +## Parsing to Double {#ParsingDouble} + +Parsing string into `double` is difficult. The standard library function `strtod()` can do the job but it is slow. By default, the parsers use normal precision setting. This has has maximum 3 [ULP](http://en.wikipedia.org/wiki/Unit_in_the_last_place) error and implemented in `internal::StrtodNormalPrecision()`. + +When using `kParseFullPrecisionFlag`, the parsers calls `internal::StrtodFullPrecision()` instead, and this function actually implemented 3 versions of conversion methods. +1. [Fast-Path](http://www.exploringbinary.com/fast-path-decimal-to-floating-point-conversion/). +2. Custom DIY-FP implementation as in [double-conversion](https://github.com/floitsch/double-conversion). +3. Big Integer Method as in (Clinger, William D. How to read floating point numbers accurately. Vol. 25. No. 6. ACM, 1990). + +If the first conversion methods fail, it will try the second, and so on. + +# Generation Optimization {#GenerationOptimization} + +## Integer-to-String conversion {#itoa} + +The naive algorithm for integer-to-string conversion involves division per each decimal digit. We have implemented various implementations and evaluated them in [itoa-benchmark](https://github.com/miloyip/itoa-benchmark). + +Although SSE2 version is the fastest but the difference is minor by comparing to the first running-up `branchlut`. And `branchlut` is pure C++ implementation so we adopt `branchlut` in RapidJSON. + +## Double-to-String conversion {#dtoa} + +Originally RapidJSON uses `snprintf(..., ..., "%g")` to achieve double-to-string conversion. This is not accurate as the default precision is 6. Later we also find that this is slow and there is an alternative. + +Google's V8 [double-conversion](https://github.com/floitsch/double-conversion +) implemented a newer, fast algorithm called Grisu3 (Loitsch, Florian. "Printing floating-point numbers quickly and accurately with integers." ACM Sigplan Notices 45.6 (2010): 233-243.). + +However, since it is not header-only so that we implemented a header-only version of Grisu2. This algorithm guarantees that the result is always accurate. And in most of cases it produces the shortest (optimal) string representation. + +The header-only conversion function has been evaluated in [dtoa-benchmark](https://github.com/miloyip/dtoa-benchmark). + +# Parser {#Parser} + +## Iterative Parser {#IterativeParser} + +The iterative parser is a recursive descent LL(1) parser +implemented in a non-recursive manner. + +### Grammar {#IterativeParserGrammar} + +The grammar used for this parser is based on strict JSON syntax: +~~~~~~~~~~ +S -> array | object +array -> [ values ] +object -> { members } +values -> non-empty-values | ε +non-empty-values -> value addition-values +addition-values -> ε | , non-empty-values +members -> non-empty-members | ε +non-empty-members -> member addition-members +addition-members -> ε | , non-empty-members +member -> STRING : value +value -> STRING | NUMBER | NULL | BOOLEAN | object | array +~~~~~~~~~~ + +Note that left factoring is applied to non-terminals `values` and `members` +to make the grammar be LL(1). + +### Parsing Table {#IterativeParserParsingTable} + +Based on the grammar, we can construct the FIRST and FOLLOW set. + +The FIRST set of non-terminals is listed below: + +| NON-TERMINAL | FIRST | +|:-----------------:|:--------------------------------:| +| array | [ | +| object | { | +| values | ε STRING NUMBER NULL BOOLEAN { [ | +| addition-values | ε COMMA | +| members | ε STRING | +| addition-members | ε COMMA | +| member | STRING | +| value | STRING NUMBER NULL BOOLEAN { [ | +| S | [ { | +| non-empty-members | STRING | +| non-empty-values | STRING NUMBER NULL BOOLEAN { [ | + +The FOLLOW set is listed below: + +| NON-TERMINAL | FOLLOW | +|:-----------------:|:-------:| +| S | $ | +| array | , $ } ] | +| object | , $ } ] | +| values | ] | +| non-empty-values | ] | +| addition-values | ] | +| members | } | +| non-empty-members | } | +| addition-members | } | +| member | , } | +| value | , } ] | + +Finally the parsing table can be constructed from FIRST and FOLLOW set: + +| NON-TERMINAL | [ | { | , | : | ] | } | STRING | NUMBER | NULL | BOOLEAN | +|:-----------------:|:---------------------:|:---------------------:|:-------------------:|:-:|:-:|:-:|:-----------------------:|:---------------------:|:---------------------:|:---------------------:| +| S | array | object | | | | | | | | | +| array | [ values ] | | | | | | | | | | +| object | | { members } | | | | | | | | | +| values | non-empty-values | non-empty-values | | | ε | | non-empty-values | non-empty-values | non-empty-values | non-empty-values | +| non-empty-values | value addition-values | value addition-values | | | | | value addition-values | value addition-values | value addition-values | value addition-values | +| addition-values | | | , non-empty-values | | ε | | | | | | +| members | | | | | | ε | non-empty-members | | | | +| non-empty-members | | | | | | | member addition-members | | | | +| addition-members | | | , non-empty-members | | | ε | | | | | +| member | | | | | | | STRING : value | | | | +| value | array | object | | | | | STRING | NUMBER | NULL | BOOLEAN | + +There is a great [tool](http://hackingoff.com/compilers/predict-first-follow-set) for above grammar analysis. + +### Implementation {#IterativeParserImplementation} + +Based on the parsing table, a direct(or conventional) implementation +that pushes the production body in reverse order +while generating a production could work. + +In RapidJSON, several modifications(or adaptations to current design) are made to a direct implementation. + +First, the parsing table is encoded in a state machine in RapidJSON. +States are constructed by the head and body of production. +State transitions are constructed by production rules. +Besides, extra states are added for productions involved with `array` and `object`. +In this way the generation of array values or object members would be a single state transition, +rather than several pop/push operations in the direct implementation. +This also makes the estimation of stack size more easier. + +The state diagram is shown as follows: + +![State Diagram](diagram/iterative-parser-states-diagram.png) + +Second, the iterative parser also keeps track of array's value count and object's member count +in its internal stack, which may be different from a conventional implementation. http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/logo/rapidjson.png ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/logo/rapidjson.png b/thirdparty/rapidjson-1.1.0/doc/logo/rapidjson.png new file mode 100644 index 0000000..b3b2f80 Binary files /dev/null and b/thirdparty/rapidjson-1.1.0/doc/logo/rapidjson.png differ http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/logo/rapidjson.svg ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/logo/rapidjson.svg b/thirdparty/rapidjson-1.1.0/doc/logo/rapidjson.svg new file mode 100644 index 0000000..9708d5a --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/logo/rapidjson.svg @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="217.15039" + height="60.831055" + id="svg2" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="rapidjson.svg"> + <defs + id="defs4"> + <linearGradient + id="linearGradient3801"> + <stop + style="stop-color:#000000;stop-opacity:1;" + offset="0" + id="stop3803" /> + <stop + style="stop-color:#000000;stop-opacity:0;" + offset="1" + id="stop3805" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3801" + id="linearGradient3807" + x1="81.25" + y1="52.737183" + x2="122.25" + y2="52.737183" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1.2378503,0,0,1.1662045,-226.99279,64.427324)" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3801" + id="linearGradient3935" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(-1.4768835,0,0,2.2904698,246.48785,81.630301)" + x1="81.25" + y1="52.737183" + x2="115.96579" + y2="48.439766" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3801" + id="linearGradient3947" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1.2378503,0,0,1.1662045,-226.99279,-10.072676)" + x1="81.25" + y1="52.737183" + x2="122.25" + y2="52.737183" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="2" + inkscape:cx="207.8959" + inkscape:cy="-3.2283687" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1920" + inkscape:window-height="1137" + inkscape:window-x="-8" + inkscape:window-y="-8" + inkscape:window-maximized="1" + fit-margin-top="10" + fit-margin-left="10" + fit-margin-right="10" + fit-margin-bottom="10" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(-39.132812,-38.772339)"> + <text + sodipodi:linespacing="125%" + id="text3939" + y="79.862183" + x="147.5" + style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Microsoft JhengHei;-inkscape-font-specification:Microsoft JhengHei" + xml:space="preserve"><tspan + style="font-size:48px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Inconsolata;-inkscape-font-specification:Inconsolata" + y="79.862183" + x="147.5" + id="tspan3941" + sodipodi:role="line"><tspan + id="tspan3943" + style="font-size:42px;font-style:oblique;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Segoe UI;-inkscape-font-specification:Segoe UI Oblique">Rapid</tspan><tspan + id="tspan3945" + style="font-weight:bold;-inkscape-font-specification:Inconsolata Bold">JSON</tspan></tspan></text> + </g> +</svg> http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/misc/DoxygenLayout.xml ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/misc/DoxygenLayout.xml b/thirdparty/rapidjson-1.1.0/doc/misc/DoxygenLayout.xml new file mode 100644 index 0000000..b7c9586 --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/misc/DoxygenLayout.xml @@ -0,0 +1,194 @@ +<doxygenlayout version="1.0"> + <!-- Generated by doxygen 1.8.7 --> + <!-- Navigation index tabs for HTML output --> + <navindex> + <tab type="mainpage" visible="yes" title=""/> + <tab type="pages" visible="yes" title="" intro=""/> + <tab type="modules" visible="yes" title="" intro=""/> + <tab type="namespaces" visible="yes" title=""> + <tab type="namespacelist" visible="yes" title="" intro=""/> + <tab type="namespacemembers" visible="yes" title="" intro=""/> + </tab> + <tab type="classes" visible="yes" title=""> + <tab type="classlist" visible="yes" title="" intro=""/> + <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/> + <tab type="hierarchy" visible="yes" title="" intro=""/> + <tab type="classmembers" visible="yes" title="" intro=""/> + </tab> + <tab type="files" visible="yes" title=""> + <tab type="filelist" visible="yes" title="" intro=""/> + <tab type="globals" visible="yes" title="" intro=""/> + </tab> + <tab type="examples" visible="yes" title="" intro=""/> + </navindex> + + <!-- Layout definition for a class page --> + <class> + <briefdescription visible="yes"/> + <includes visible="$SHOW_INCLUDE_FILES"/> + <inheritancegraph visible="$CLASS_GRAPH"/> + <collaborationgraph visible="$COLLABORATION_GRAPH"/> + <memberdecl> + <nestedclasses visible="yes" title=""/> + <publictypes title=""/> + <services title=""/> + <interfaces title=""/> + <publicslots title=""/> + <signals title=""/> + <publicmethods title=""/> + <publicstaticmethods title=""/> + <publicattributes title=""/> + <publicstaticattributes title=""/> + <protectedtypes title=""/> + <protectedslots title=""/> + <protectedmethods title=""/> + <protectedstaticmethods title=""/> + <protectedattributes title=""/> + <protectedstaticattributes title=""/> + <packagetypes title=""/> + <packagemethods title=""/> + <packagestaticmethods title=""/> + <packageattributes title=""/> + <packagestaticattributes title=""/> + <properties title=""/> + <events title=""/> + <privatetypes title=""/> + <privateslots title=""/> + <privatemethods title=""/> + <privatestaticmethods title=""/> + <privateattributes title=""/> + <privatestaticattributes title=""/> + <friends title=""/> + <related title="" subtitle=""/> + <membergroups visible="yes"/> + </memberdecl> + <detaileddescription title=""/> + <memberdef> + <inlineclasses title=""/> + <typedefs title=""/> + <enums title=""/> + <services title=""/> + <interfaces title=""/> + <constructors title=""/> + <functions title=""/> + <related title=""/> + <variables title=""/> + <properties title=""/> + <events title=""/> + </memberdef> + <allmemberslink visible="yes"/> + <usedfiles visible="$SHOW_USED_FILES"/> + <authorsection visible="yes"/> + </class> + + <!-- Layout definition for a namespace page --> + <namespace> + <briefdescription visible="yes"/> + <memberdecl> + <nestednamespaces visible="yes" title=""/> + <constantgroups visible="yes" title=""/> + <classes visible="yes" title=""/> + <typedefs title=""/> + <enums title=""/> + <functions title=""/> + <variables title=""/> + <membergroups visible="yes"/> + </memberdecl> + <detaileddescription title=""/> + <memberdef> + <inlineclasses title=""/> + <typedefs title=""/> + <enums title=""/> + <functions title=""/> + <variables title=""/> + </memberdef> + <authorsection visible="yes"/> + </namespace> + + <!-- Layout definition for a file page --> + <file> + <briefdescription visible="yes"/> + <includes visible="$SHOW_INCLUDE_FILES"/> + <includegraph visible="$INCLUDE_GRAPH"/> + <includedbygraph visible="$INCLUDED_BY_GRAPH"/> + <sourcelink visible="yes"/> + <memberdecl> + <classes visible="yes" title=""/> + <namespaces visible="yes" title=""/> + <constantgroups visible="yes" title=""/> + <defines title=""/> + <typedefs title=""/> + <enums title=""/> + <functions title=""/> + <variables title=""/> + <membergroups visible="yes"/> + </memberdecl> + <detaileddescription title=""/> + <memberdef> + <inlineclasses title=""/> + <defines title=""/> + <typedefs title=""/> + <enums title=""/> + <functions title=""/> + <variables title=""/> + </memberdef> + <authorsection/> + </file> + + <!-- Layout definition for a group page --> + <group> + <briefdescription visible="yes"/> + <groupgraph visible="$GROUP_GRAPHS"/> + <memberdecl> + <nestedgroups visible="yes" title=""/> + <dirs visible="yes" title=""/> + <files visible="yes" title=""/> + <namespaces visible="yes" title=""/> + <classes visible="yes" title=""/> + <defines title=""/> + <typedefs title=""/> + <enums title=""/> + <enumvalues title=""/> + <functions title=""/> + <variables title=""/> + <signals title=""/> + <publicslots title=""/> + <protectedslots title=""/> + <privateslots title=""/> + <events title=""/> + <properties title=""/> + <friends title=""/> + <membergroups visible="yes"/> + </memberdecl> + <detaileddescription title=""/> + <memberdef> + <pagedocs/> + <inlineclasses title=""/> + <defines title=""/> + <typedefs title=""/> + <enums title=""/> + <enumvalues title=""/> + <functions title=""/> + <variables title=""/> + <signals title=""/> + <publicslots title=""/> + <protectedslots title=""/> + <privateslots title=""/> + <events title=""/> + <properties title=""/> + <friends title=""/> + </memberdef> + <authorsection visible="yes"/> + </group> + + <!-- Layout definition for a directory page --> + <directory> + <briefdescription visible="yes"/> + <directorygraph visible="yes"/> + <memberdecl> + <dirs visible="yes"/> + <files visible="yes"/> + </memberdecl> + <detaileddescription title=""/> + </directory> +</doxygenlayout> http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/misc/doxygenextra.css ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/misc/doxygenextra.css b/thirdparty/rapidjson-1.1.0/doc/misc/doxygenextra.css new file mode 100644 index 0000000..bd67375 --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/misc/doxygenextra.css @@ -0,0 +1,274 @@ +body code { + margin: 0; + border: 1px solid #ddd; + background-color: #f8f8f8; + border-radius: 3px; + padding: 0; +} + +a { + color: #4183c4; +} + +a.el { + font-weight: normal; +} + +body, table, div, p, dl { + color: #333333; + font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; + font-size: 15px; + font-style: normal; + font-variant: normal; + font-weight: normal; + line-height: 25.5px; +} + +body { + background-color: #eee; +} + +div.header { + background-image: none; + background-color: white; + margin: 0px; + border: 0px; +} + +div.headertitle { + width: 858px; + margin: 30px; + padding: 0px; +} + +div.toc { + background-color: #f8f8f8; + border-color: #ddd; + margin-right: 10px; + margin-left: 20px; +} +div.toc h3 { + color: #333333; + font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; + font-size: 18px; + font-style: normal; + font-variant: normal; + font-weight: normal; +} +div.toc li { + color: #333333; + font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; + font-size: 12px; + font-style: normal; + font-variant: normal; + font-weight: normal; +} + +.title { + font-size: 2.5em; + line-height: 63.75px; + border-bottom: 1px solid #ddd; + margin-bottom: 15px; + margin-left: 0px; + margin-right: 0px; + margin-top: 0px; +} + +.summary { + float: none !important; + width: auto !important; + padding-top: 10px; + padding-right: 10px !important; +} + +.summary + .headertitle .title { + font-size: 1.5em; + line-height: 2.0em; +} + +body h1 { + font-size: 2em; + line-height: 1.7; + border-bottom: 1px solid #eee; + margin: 1em 0 15px; + padding: 0; + overflow: hidden; +} + +body h2 { + font-size: 1.5em; + line-height: 1.7; + margin: 1em 0 15px; + padding: 0; +} + +pre.fragment { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 13px; + font-style: normal; + font-variant: normal; + font-weight: normal; + line-height: 19px; +} + +table.doxtable th { + background-color: #f8f8f8; + color: #333333; + font-size: 15px; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #ddd; +} + +#doc-content { + background-color: #fff; + width: 918px; + height: auto !important; + margin-left: 270px !important; +} + +div.contents { + width: 858px; + margin: 30px; +} + +div.line { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 13px; + font-style: normal; + font-variant: normal; + font-weight: normal; + line-height: 19px; +} + +tt, code, pre { + font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; + font-size: 12px; +} + +div.fragment { + background-color: #f8f8f8; + border: 1px solid #ddd; + font-size: 13px; + line-height: 19px; + overflow: auto; + padding: 6px 10px; + border-radius: 3px; +} + +#topbanner { + position: fixed; + margin: 15px; + z-index: 101; +} + +#projectname +{ + font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; + font-size: 38px; + font-weight: bold; + line-height: 63.75px; + margin: 0px; + padding: 2px 0px; +} + +#projectbrief +{ + font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; + font-size: 16px; + line-height: 22.4px; + margin: 0px 0px 13px 0px; + padding: 2px; +} + +/* side bar and search */ + +#side-nav +{ + padding: 10px 0px 20px 20px; + border-top: 60px solid #2980b9; + background-color: #343131; + width: 250px !important; + height: 100% !important; + position: fixed; +} + +#nav-tree +{ + background-color: transparent; + background-image: none; + height: 100% !important; +} + +#nav-tree .label +{ + font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; + line-height: 25.5px; + font-size: 15px; +} + +#nav-tree +{ + color: #b3b3b3; +} + +#nav-tree .selected { + background-image: none; +} + +#nav-tree a +{ + color: #b3b3b3; +} + +#github +{ + position: fixed; + left: auto; + right: auto; + width: 250px; +} + +#MSearchBox +{ + margin: 20px; + left: 40px; + right: auto; + position: fixed; + width: 180px; +} + +#MSearchField +{ + width: 121px; +} + +#MSearchResultsWindow +{ + left: 45px !important; +} + +#nav-sync +{ + display: none; +} + +.ui-resizable .ui-resizable-handle +{ + width: 0px; +} + +#nav-path +{ + display: none; +} + +/* external link icon */ +div.contents a[href ^= "http"]:after { + content: " " url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAVklEQVR4Xn3PgQkAMQhDUXfqTu7kTtkpd5RA8AInfArtQ2iRXFWT2QedAfttj2FsPIOE1eCOlEuoWWjgzYaB/IkeGOrxXhqB+uA9Bfcm0lAZuh+YIeAD+cAqSz4kCMUAAAAASUVORK5CYII=); +} + +.githublogo { + content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RERCMUIwOUY4NkNFMTFFM0FBNTJFRTMzNTJEMUJDNDYiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RERCMUIwOUU4NkNFMTFFM0FBNTJFRTMzNTJEMUJDNDYiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAua WlkOkU1MTc4QTJBOTlBMDExRTI5QTE1QkMxMDQ2QTg5MDREIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU1MTc4QTJCOTlBMDExRTI5QTE1QkMxMDQ2QTg5MDREIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+jUqS1wAAApVJREFUeNq0l89rE1EQx3e3gVJoSPzZeNEWPKgHoa0HBak0iHiy/4C3WvDmoZ56qJ7txVsPQu8qlqqHIhRKJZceesmhioQEfxTEtsoSpdJg1u/ABJ7Pmc1m8zLwgWTmzcw3L+/te+tHUeQltONgCkyCi2AEDHLsJ6iBMlgHL8FeoqokoA2j4CloRMmtwTmj7erHBXPgCWhG6a3JNXKdCiDl1cidVbXZkJoXQRi5t5BrxwoY71FzU8S4JuAIqFkJ2+BFSlEh525b/hr3+k/AklDkNsf6wTT4yv46KIMNpsy+iMdMc47HNWxbsgVcUn7FmLAzzoFAWDsBx+wVP6bUpp5ewI+DOeUx0Wd9D8F70BTGNjkWtqnhmT1JQAHcUgZd8Lo3rQb1LAT8eJVUfgGvHQigGp+V2Z0iAUUl8QH47kAA1XioxIo+bRN8OG8F/oBjwv+Z1nJgX5jpdzQDw0LCjsPmrcW7I/iHScCAEDj03FtD8A0EyuChHgg4KTlJQF3wZ7WELppnBX+dBFSVpJsOBWi1qiRgSwnOgoyD5hmuJdkWCVhTgnTvW3AgYIFrSbZGh0UW/Io5Vp+DQoK7o80pztWMemZbgxeNwCNwDbw1fIfgGZjhU6xPaJgBV8BdsMw5cbZoHsenwYFxkZzl83xTSKTiviCAfCsJLysH3POfC8m8NegyGAGfLP/VmGmfSChgXroR0RSWjEFv2J/nG84cuKFMf4sTCZqXuJd4KaXFVjEG3+tw4eXbNK/YC9oXXs3O8NY8y9 9L4BXY5cvLY/Bb2VZ58EOJVcB18DHJq9lRsKr8inyKGVjlmh29mtHs3AHfuhCwy1vXT/Nu2GKQt+UHsGdctyX6eQyNvc+5sfX9Dl7Pe2J/BRgAl2CpwmrsHR0AAAAASUVORK5CYII=); +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/misc/footer.html ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/misc/footer.html b/thirdparty/rapidjson-1.1.0/doc/misc/footer.html new file mode 100644 index 0000000..77f1131 --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/misc/footer.html @@ -0,0 +1,11 @@ +<!-- HTML footer for doxygen 1.8.7--> +<!-- start footer part --> +<!--BEGIN GENERATE_TREEVIEW--> +<div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> + <ul> + $navpath + </ul> +</div> +<!--END GENERATE_TREEVIEW--> +</body> +</html> http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/misc/header.html ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/misc/header.html b/thirdparty/rapidjson-1.1.0/doc/misc/header.html new file mode 100644 index 0000000..2dbe721 --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/misc/header.html @@ -0,0 +1,24 @@ +<!-- HTML header for doxygen 1.8.7--> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> +<meta http-equiv="X-UA-Compatible" content="IE=9"/> +<meta name="generator" content="Doxygen $doxygenversion"/> +<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME--> +<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME--> +<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/> +<script type="text/javascript" src="$relpath^jquery.js"></script> +<script type="text/javascript" src="$relpath^dynsections.js"></script> +$treeview +$search +$mathjax +<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" /> +$extrastylesheet +</head> +<body> +<div id="top"><!-- do not remove this div, it is closed by doxygen! --> +<div id="topbanner"><a href="https://github.com/miloyip/rapidjson" title="RapidJSON GitHub"><i class="githublogo"></i></a></div> +$searchbox +<!--END TITLEAREA--> +<!-- end header part --> http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/npm.md ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/npm.md b/thirdparty/rapidjson-1.1.0/doc/npm.md new file mode 100644 index 0000000..5efa768 --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/npm.md @@ -0,0 +1,31 @@ +## NPM + +# package.json {#package} + +~~~~~~~~~~js +{ + ... + "dependencies": { + ... + "rapidjson": "g...@github.com:miloyip/rapidjson.git" + }, + ... + "gypfile": true +} +~~~~~~~~~~ + +# binding.gyp {#binding} + +~~~~~~~~~~js +{ + ... + 'targets': [ + { + ... + 'include_dirs': [ + '<!(node -e \'require("rapidjson")\')' + ] + } + ] +} +~~~~~~~~~~ http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/performance.md ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/performance.md b/thirdparty/rapidjson-1.1.0/doc/performance.md new file mode 100644 index 0000000..988e799 --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/performance.md @@ -0,0 +1,26 @@ +# Performance + +There is a [native JSON benchmark collection] [1] which evaluates speed, memory usage and code size of various operations among 37 JSON libaries. + +[1]: https://github.com/miloyip/nativejson-benchmark + +The old performance article for RapidJSON 0.1 is provided [here](https://code.google.com/p/rapidjson/wiki/Performance). + +Additionally, you may refer to the following third-party benchmarks. + +## Third-party benchmarks + +* [Basic benchmarks for miscellaneous C++ JSON parsers and generators](https://github.com/mloskot/json_benchmark) by Mateusz Loskot (Jun 2013) + * [casablanca](https://casablanca.codeplex.com/) + * [json_spirit](https://github.com/cierelabs/json_spirit) + * [jsoncpp](http://jsoncpp.sourceforge.net/) + * [libjson](http://sourceforge.net/projects/libjson/) + * [rapidjson](https://github.com/miloyip/rapidjson/) + * [QJsonDocument](http://qt-project.org/doc/qt-5.0/qtcore/qjsondocument.html) + +* [JSON Parser Benchmarking](http://chadaustin.me/2013/01/json-parser-benchmarking/) by Chad Austin (Jan 2013) + * [sajson](https://github.com/chadaustin/sajson) + * [rapidjson](https://github.com/miloyip/rapidjson/) + * [vjson](https://code.google.com/p/vjson/) + * [YAJL](http://lloyd.github.com/yajl/) + * [Jansson](http://www.digip.org/jansson/) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/performance.zh-cn.md ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/performance.zh-cn.md b/thirdparty/rapidjson-1.1.0/doc/performance.zh-cn.md new file mode 100644 index 0000000..c20c505 --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/performance.zh-cn.md @@ -0,0 +1,26 @@ +# æ§è½ + +æä¸ä¸ª [native JSON benchmark collection][1] 项ç®ï¼è½è¯ä¼° 37 个 JSON åºå¨ä¸åæä½ä¸çé度ãå §åç¨éå代ç 大å°ã + +[1]: https://github.com/miloyip/nativejson-benchmark + +RapidJSON 0.1 çæ¬çæ§è½æµè¯æç« ä½äº [è¿é](https://code.google.com/p/rapidjson/wiki/Performance). + +æ¤å¤ï¼ä½ ä¹å¯ä»¥åè以ä¸è¿äºç¬¬ä¸æ¹çè¯æµã + +## 第ä¸æ¹è¯æµ + +* [Basic benchmarks for miscellaneous C++ JSON parsers and generators](https://github.com/mloskot/json_benchmark) by Mateusz Loskot (Jun 2013) + * [casablanca](https://casablanca.codeplex.com/) + * [json_spirit](https://github.com/cierelabs/json_spirit) + * [jsoncpp](http://jsoncpp.sourceforge.net/) + * [libjson](http://sourceforge.net/projects/libjson/) + * [rapidjson](https://github.com/miloyip/rapidjson/) + * [QJsonDocument](http://qt-project.org/doc/qt-5.0/qtcore/qjsondocument.html) + +* [JSON Parser Benchmarking](http://chadaustin.me/2013/01/json-parser-benchmarking/) by Chad Austin (Jan 2013) + * [sajson](https://github.com/chadaustin/sajson) + * [rapidjson](https://github.com/miloyip/rapidjson/) + * [vjson](https://code.google.com/p/vjson/) + * [YAJL](http://lloyd.github.com/yajl/) + * [Jansson](http://www.digip.org/jansson/) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fd280b5c/thirdparty/rapidjson-1.1.0/doc/pointer.md ---------------------------------------------------------------------- diff --git a/thirdparty/rapidjson-1.1.0/doc/pointer.md b/thirdparty/rapidjson-1.1.0/doc/pointer.md new file mode 100644 index 0000000..b343d78 --- /dev/null +++ b/thirdparty/rapidjson-1.1.0/doc/pointer.md @@ -0,0 +1,234 @@ +# Pointer + +(This feature was released in v1.1.0) + +JSON Pointer is a standardized ([RFC6901]) way to select a value inside a JSON Document (DOM). This can be analogous to XPath for XML document. However, JSON Pointer is much simpler, and a single JSON Pointer only pointed to a single value. + +Using RapidJSON's implementation of JSON Pointer can simplify some manipulations of the DOM. + +[TOC] + +# JSON Pointer {#JsonPointer} + +A JSON Pointer is a list of zero-to-many tokens, each prefixed by `/`. Each token can be a string or a number. For example, given a JSON: +~~~javascript +{ + "foo" : ["bar", "baz"], + "pi" : 3.1416 +} +~~~ + +The following JSON Pointers resolve this JSON as: + +1. `"/foo"` â `[ "bar", "baz" ]` +2. `"/foo/0"` â `"bar"` +3. `"/foo/1"` â `"baz"` +4. `"/pi"` â `3.1416` + +Note that, an empty JSON Pointer `""` (zero token) resolves to the whole JSON. + +# Basic Usage {#BasicUsage} + +The following example code is self-explanatory. + +~~~cpp +#include "rapidjson/pointer.h" + +// ... +Document d; + +// Create DOM by Set() +Pointer("/project").Set(d, "RapidJSON"); +Pointer("/stars").Set(d, 10); + +// { "project" : "RapidJSON", "stars" : 10 } + +// Access DOM by Get(). It return nullptr if the value does not exist. +if (Value* stars = Pointer("/stars").Get(d)) + stars->SetInt(stars->GetInt() + 1); + +// { "project" : "RapidJSON", "stars" : 11 } + +// Set() and Create() automatically generate parents if not exist. +Pointer("/a/b/0").Create(d); + +// { "project" : "RapidJSON", "stars" : 11, "a" : { "b" : [ null ] } } + +// GetWithDefault() returns reference. And it deep clones the default value. +Value& hello = Pointer("/hello").GetWithDefault(d, "world"); + +// { "project" : "RapidJSON", "stars" : 11, "a" : { "b" : [ null ] }, "hello" : "world" } + +// Swap() is similar to Set() +Value x("C++"); +Pointer("/hello").Swap(d, x); + +// { "project" : "RapidJSON", "stars" : 11, "a" : { "b" : [ null ] }, "hello" : "C++" } +// x becomes "world" + +// Erase a member or element, return true if the value exists +bool success = Pointer("/a").Erase(d); +assert(success); + +// { "project" : "RapidJSON", "stars" : 10 } +~~~ + +# Helper Functions {#HelperFunctions} + +Since object-oriented calling convention may be non-intuitive, RapidJSON also provides helper functions, which just wrap the member functions with free-functions. + +The following example does exactly the same as the above one. + +~~~cpp +Document d; + +SetValueByPointer(d, "/project", "RapidJSON"); +SetValueByPointer(d, "/stars", 10); + +if (Value* stars = GetValueByPointer(d, "/stars")) + stars->SetInt(stars->GetInt() + 1); + +CreateValueByPointer(d, "/a/b/0"); + +Value& hello = GetValueByPointerWithDefault(d, "/hello", "world"); + +Value x("C++"); +SwapValueByPointer(d, "/hello", x); + +bool success = EraseValueByPointer(d, "/a"); +assert(success); +~~~ + +The conventions are shown here for comparison: + +1. `Pointer(source).<Method>(root, ...)` +2. `<Method>ValueByPointer(root, Pointer(source), ...)` +3. `<Method>ValueByPointer(root, source, ...)` + +# Resolving Pointer {#ResolvingPointer} + +`Pointer::Get()` or `GetValueByPointer()` function does not modify the DOM. If the tokens cannot match a value in the DOM, it returns `nullptr`. User can use this to check whether a value exists. + +Note that, numerical tokens can represent an array index or member name. The resolving process will match the values according to the types of value. + +~~~javascript +{ + "0" : 123, + "1" : [456] +} +~~~ + +1. `"/0"` â `123` +2. `"/1/0"` â `456` + +The token `"0"` is treated as member name in the first pointer. It is treated as an array index in the second pointer. + +The other functions, including `Create()`, `GetWithDefault()`, `Set()` and `Swap()`, will change the DOM. These functions will always succeed. They will create the parent values if they do not exist. If the parent values do not match the tokens, they will also be forced to change their type. Changing the type also mean fully removal of that DOM subtree. + +Parsing the above JSON into `d`, + +~~~cpp +SetValueByPointer(d, "1/a", 789); // { "0" : 123, "1" : { "a" : 789 } } +~~~ + +## Resolving Minus Sign Token + +Besides, [RFC6901] defines a special token `-` (single minus sign), which represents the pass-the-end element of an array. `Get()` only treats this token as a member name '"-"'. Yet the other functions can resolve this for array, equivalent to calling `Value::PushBack()` to the array. + +~~~cpp +Document d; +d.Parse("{\"foo\":[123]}"); +SetValueByPointer(d, "/foo/-", 456); // { "foo" : [123, 456] } +SetValueByPointer(d, "/-", 789); // { "foo" : [123, 456], "-" : 789 } +~~~ + +## Resolving Document and Value + +When using `p.Get(root)` or `GetValueByPointer(root, p)`, `root` is a (const) `Value&`. That means, it can be a subtree of the DOM. + +The other functions have two groups of signature. One group uses `Document& document` as parameter, another one uses `Value& root`. The first group uses `document.GetAllocator()` for creating values. And the second group needs user to supply an allocator, like the functions in DOM. + +All examples above do not require an allocator parameter, because the first parameter is a `Document&`. But if you want to resolve a pointer to a subtree, you need to supply the allocator as in the following example: + +~~~cpp +class Person { +public: + Person() { + document_ = new Document(); + // CreateValueByPointer() here no need allocator + SetLocation(CreateValueByPointer(*document_, "/residence"), ...); + SetLocation(CreateValueByPointer(*document_, "/office"), ...); + }; + +private: + void SetLocation(Value& location, const char* country, const char* addresses[2]) { + Value::Allocator& a = document_->GetAllocator(); + // SetValueByPointer() here need allocator + SetValueByPointer(location, "/country", country, a); + SetValueByPointer(location, "/address/0", address[0], a); + SetValueByPointer(location, "/address/1", address[1], a); + } + + // ... + + Document* document_; +}; +~~~ + +`Erase()` or `EraseValueByPointer()` does not need allocator. And they return `true` if the value is erased successfully. + +# Error Handling {#ErrorHandling} + +A `Pointer` parses a source string in its constructor. If there is parsing error, `Pointer::IsValid()` returns `false`. And you can use `Pointer::GetParseErrorCode()` and `GetParseErrorOffset()` to retrieve the error information. + +Note that, all resolving functions assumes valid pointer. Resolving with an invalid pointer causes assertion failure. + +# URI Fragment Representation {#URIFragment} + +In addition to the string representation of JSON pointer that we are using till now, [RFC6901] also defines the URI fragment representation of JSON pointer. URI fragment is specified in [RFC3986] "Uniform Resource Identifier (URI): Generic Syntax". + +The main differences are that a the URI fragment always has a `#` (pound sign) in the beginning, and some characters are encoded by percent-encoding in UTF-8 sequence. For example, the following table shows different C/C++ string literals of different representations. + +String Representation | URI Fragment Representation | Pointer Tokens (UTF-8) +----------------------|-----------------------------|------------------------ +`"/foo/0"` | `"#/foo/0"` | `{"foo", 0}` +`"/a~1b"` | `"#/a~1b"` | `{"a/b"}` +`"/m~0n"` | `"#/m~0n"` | `{"m~n"}` +`"/ "` | `"#/%20"` | `{" "}` +`"/\0"` | `"#/%00"` | `{"\0"}` +`"/â¬"` | `"#/%E2%82%AC"` | `{"â¬"}` + +RapidJSON fully support URI fragment representation. It automatically detects the pound sign during parsing. + +# Stringify + +You may also stringify a `Pointer` to a string or other output streams. This can be done by: + +~~~ +Pointer p(...); +StringBuffer sb; +p.Stringify(sb); +std::cout << sb.GetString() << std::endl; +~~~ + +It can also stringify to URI fragment reprsentation by `StringifyUriFragment()`. + +# User-Supplied Tokens {#UserSuppliedTokens} + +If a pointer will be resolved multiple times, it should be constructed once, and then apply it to different DOMs or in different times. This reduce time and memory allocation for constructing `Pointer` multiple times. + +We can go one step further, to completely eliminate the parsing process and dynamic memory allocation, we can establish the token array directly: + +~~~cpp +#define NAME(s) { s, sizeof(s) / sizeof(s[0]) - 1, kPointerInvalidIndex } +#define INDEX(i) { #i, sizeof(#i) - 1, i } + +static const Pointer::Token kTokens[] = { NAME("foo"), INDEX(123) }; +static const Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0])); +// Equivalent to static const Pointer p("/foo/123"); +~~~ + +This may be useful for memory constrained systems. + +[RFC3986]: https://tools.ietf.org/html/rfc3986 +[RFC6901]: https://tools.ietf.org/html/rfc6901