├── release ├── docs │ ├── hx │ │ ├── extra-styles.css │ │ ├── favicon.ico │ │ ├── triangle-closed.png │ │ ├── triangle-opened.png │ │ ├── bootstrap │ │ │ ├── img │ │ │ │ ├── glyphicons-halflings.png │ │ │ │ └── glyphicons-halflings-white.png │ │ │ └── css │ │ │ │ └── bootstrap-select.min.css │ │ ├── highlighter.css │ │ ├── nav.js │ │ ├── highlighter.js │ │ ├── 404.html │ │ ├── acsv │ │ │ ├── index.html │ │ │ └── Field.html │ │ ├── Dynamic.html │ │ ├── index.html │ │ ├── Float.html │ │ ├── Int.html │ │ ├── haxe-nav.css │ │ ├── Array.html │ │ ├── index.js │ │ ├── styles.css │ │ └── String.html │ └── clock_in.txt ├── csvs │ ├── standard_format_text.csv │ └── enhanced_format_text.csv ├── js │ └── demo.html └── ts │ ├── demo.html │ └── demo.js ├── src ├── csharp │ ├── Newtonsoft.Json.dll │ ├── README.md │ └── Demo.cs ├── golang │ ├── src │ │ └── acsv │ │ │ └── Field.go │ ├── README.md │ └── Demo.go ├── haxe │ ├── README.md │ ├── acsv │ │ └── Field.hx │ └── Demo.hx ├── php │ ├── README.md │ └── demo.php ├── python │ ├── README.md │ └── demo.py ├── javascript │ ├── README.md │ └── ACsv.min.js ├── java │ ├── README.md │ ├── acsv │ │ └── Field.java │ ├── org │ │ └── json │ │ │ ├── JSONException.java │ │ │ ├── JSON.java │ │ │ └── JSONStringer.java │ └── Demo.java └── typescript │ ├── README.md │ ├── Demo.ts │ └── ACsv.d.ts ├── .gitignore ├── .gitattributes ├── tsconfig.demo.json ├── CMDs.txt ├── LICENSE ├── languages ├── 中文.md ├── 日本語.md ├── tiếng_việt.md ├── indonesia.md ├── portugués.md ├── русский.md ├── español.md └── français.md └── README.md /release/docs/hx/extra-styles.css: -------------------------------------------------------------------------------- 1 | /** to be overridden in sub-themes */ -------------------------------------------------------------------------------- /release/docs/clock_in.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amin2312/ACsv/HEAD/release/docs/clock_in.txt -------------------------------------------------------------------------------- /release/docs/hx/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amin2312/ACsv/HEAD/release/docs/hx/favicon.ico -------------------------------------------------------------------------------- /src/csharp/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amin2312/ACsv/HEAD/src/csharp/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /release/docs/hx/triangle-closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amin2312/ACsv/HEAD/release/docs/hx/triangle-closed.png -------------------------------------------------------------------------------- /release/docs/hx/triangle-opened.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amin2312/ACsv/HEAD/release/docs/hx/triangle-opened.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | package-lock.json 3 | .vscode 4 | *.pyc 5 | src/csharp/*.exe 6 | src/csharp/*.pdb 7 | src/golang/*.exe -------------------------------------------------------------------------------- /release/docs/hx/bootstrap/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amin2312/ACsv/HEAD/release/docs/hx/bootstrap/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /release/docs/hx/bootstrap/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amin2312/ACsv/HEAD/release/docs/hx/bootstrap/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /src/golang/src/acsv/Field.go: -------------------------------------------------------------------------------- 1 | package acsv 2 | 3 | type Field struct { 4 | /** 5 | * Full Name. 6 | */ 7 | FullName string 8 | /** 9 | * Name. 10 | */ 11 | Name string 12 | /** 13 | * Type. 14 | */ 15 | Type string 16 | } 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | release/docs/* linguist-vendored=true 2 | release/docs/** linguist-vendored=true 3 | src/java/org/** linguist-vendored=true 4 | *.hx linguist-language=Javascript 5 | *.html linguist-language=Javascript 6 | *.css linguist-language=Javascript -------------------------------------------------------------------------------- /src/haxe/README.md: -------------------------------------------------------------------------------- 1 | How to use this library 2 | ================ 3 | ### If you want to use this library in Haxe project, 4 | ### Please add "**acsv**" folder to project 5 | ### For API details, please view "**online docs**" 6 | ### About usage, please view "**Demo.hx**" -------------------------------------------------------------------------------- /src/golang/README.md: -------------------------------------------------------------------------------- 1 | How to use this library 2 | ================ 3 | ### If you want to use this library in GO project, 4 | ### Please import "**acsv**" package in project 5 | ### For API details, please view "**online docs**" 6 | ### About usage, please view "**Demo.go**" -------------------------------------------------------------------------------- /release/csvs/standard_format_text.csv: -------------------------------------------------------------------------------- 1 | id,id2,id3,name,brief 2 | 1,20,100,John,He is a googd man 3 | 2,20,100,张三,"他是一个好人 4 | 我们都喜欢他" 5 | 3,21,100,море,"Он хороший человек 6 | мы все любим его 7 | Его девиз: 8 | ""доверяй себе""" 9 | 4,21,200,الشمس,صباح الخير 10 | 5,22,200,चंद्रमा,सुसंध्या 11 | 6,22,200,ดาว, -------------------------------------------------------------------------------- /src/php/README.md: -------------------------------------------------------------------------------- 1 | How to use this library 2 | ================ 3 | ### If you want to use this library in PHP project, 4 | ### Please require "**ACsv.php**" file 5 | ### For API details, please view "**online docs**" 6 | ### About usage, please view "**demo.php**" 7 | 8 | \* remarks: Compatible with PHP 5.4 to PHP 7.x -------------------------------------------------------------------------------- /src/python/README.md: -------------------------------------------------------------------------------- 1 | How to use this library 2 | ================ 3 | ### If you want to use this library in Python project, 4 | ### Please import "**acsv.py**" to project 5 | ### For API details, please view "**online docs**" 6 | ### About usage, please view "**demo.py**" 7 | 8 | \* remarks: Compatible with Python 2.7 to Python 3.x -------------------------------------------------------------------------------- /src/javascript/README.md: -------------------------------------------------------------------------------- 1 | How to use this library 2 | ================ 3 | ### If you want to use this library in Javascript project, 4 | ### Please load "**ACsv.min.js**" file 5 | ### For API details, please view "**online docs**" 6 | ### About usage, please view "**release/js/demo**" 7 | 8 | \* remarks: The javascript source code is generated from haxe source code -------------------------------------------------------------------------------- /src/java/README.md: -------------------------------------------------------------------------------- 1 | How to use this library 2 | ================ 3 | ### If you want to use this library in Java project, 4 | ### Please add "**acsv**" and "**org**" folder to project 5 |  | - If your project have included "org/json" package, then you can ignore it 6 | ### For API details, please view "**online docs**" 7 | ### About usage, please view "**Demo.java**" -------------------------------------------------------------------------------- /tsconfig.demo.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": true, 3 | "compilerOptions": { 4 | "strict": true, 5 | "strictNullChecks": false, 6 | "skipLibCheck": true, 7 | "target": "ES5", 8 | 9 | "rootDir": "src/typescript", 10 | "outFile": "release/ts/demo.js", 11 | }, 12 | "exclude": [ 13 | "src/haxe/*", 14 | "src/javascript/*", 15 | "release/*" 16 | ] 17 | } -------------------------------------------------------------------------------- /src/typescript/README.md: -------------------------------------------------------------------------------- 1 | How to use this library 2 | ================ 3 | ### If you want to use this library in Typescript project, 4 | ### Please reference "**ACsv.d.ts**" file 5 | ### Please load "**src/javascript/ACsv.min.js**" file 6 | ### For API details, please view "**online docs**" 7 | ### About usage, please view "**Demo.ts**" 8 | 9 | \* remarks: The javascript source code is generated from haxe source code -------------------------------------------------------------------------------- /src/csharp/README.md: -------------------------------------------------------------------------------- 1 | How to use this library 2 | ================ 3 | ### If you want to use this library in C# project, 4 | ### Please using "**acsv**" file in project 5 | ### For API details, please view "**online docs**" 6 | ### About usage, please view "**Demo.cs**" 7 |
8 | 9 | How to compile Demo.cs 10 | ================ 11 | ### Open the terminal, go to this directory, input: csc *.cs /r:Newtonsoft.Json.dll -------------------------------------------------------------------------------- /CMDs.txt: -------------------------------------------------------------------------------- 1 | // 2 | // USE haxe dox to gen docs 3 | // Please install the tools first: haxelib install dox 4 | // 5 | haxelib run dox -i release/dox/ACsv.xml -o release/docs/hx --title "ACsv library" -ex \S+ -in acsv -in Array$ -in String$ -in Int$ -in Float$ -in Dynamic$ 6 | // 7 | // USE uglify to compress js file 8 | // Please install the tools first: npm install gulp-uglify 9 | // 10 | uglifyjs src/javascript/ACsv.js -m -o src/javascript/ACsv.min.js -------------------------------------------------------------------------------- /src/java/acsv/Field.java: -------------------------------------------------------------------------------- 1 | package acsv; 2 | 3 | /** 4 | * 1. Copyright (c) 2022 amin2312 5 | * 2. Version 1.0.0 6 | * 3. MIT License 7 | * 8 | * CSV head field. 9 | */ 10 | public class Field { 11 | /** 12 | * Full Name. 13 | */ 14 | public String fullName; 15 | /** 16 | * Name. 17 | */ 18 | public String name; 19 | /** 20 | * Type. 21 | */ 22 | public String type; 23 | /** 24 | * Constructor. 25 | */ 26 | public Field() {} 27 | } 28 | -------------------------------------------------------------------------------- /src/haxe/acsv/Field.hx: -------------------------------------------------------------------------------- 1 | package acsv; 2 | 3 | /** 4 | * 1. Copyright (c) 2022 amin2312 5 | * 2. Version 1.0.0 6 | * 3. MIT License 7 | * 8 | * CSV head field. 9 | */ 10 | @:expose 11 | class Field { 12 | /** 13 | * Full Name. 14 | */ 15 | public var fullName:String; 16 | /** 17 | * Name. 18 | */ 19 | public var name:String; 20 | /** 21 | * Type. 22 | */ 23 | public var type:String; 24 | /** 25 | * Constructor. 26 | */ 27 | @:dox(hide) 28 | public function new() {} 29 | } 30 | -------------------------------------------------------------------------------- /release/csvs/enhanced_format_text.csv: -------------------------------------------------------------------------------- 1 | id:int,id2:int,id3:int,name:string,weight:number,marry:bool,education:json,tags:strings,brief 2 | 1,21,100,John,120.1,true,"[""AB""]","good,cool","Today is good day 3 | Tomorrow is good day too" 4 | 2,21,100,张三,121.2,false,"[""CD"",""EF""]",good,今天是个好日子 5 | 3,22,100,море,123.4,true,"[""GH"",""AB"",""CD""]",good,"Сегодня хороший день 6 | ""Завтра тоже хороший день""" 7 | 4,22,200,الشمس,124.5,false,"{""AA"":12}",strong,صباح الخير 8 | 5,23,200,चंद्रमा,126.7,1,"{""BB"":12}",strong,सुसंध्या 9 | 6,23,200,Emilia,,0,"{""CC"":67,""DD"":56}","strong,cool",Hoje é um bom dia 10 | 7,24,300,Ayşe,128.9,0,"{""EE"":68,""FF"":56}","strong,cool",Bugün güzel bir gün 11 | 8,24,300,陽菜乃,129.01,,"{""AC"":78,""BD"":[90,12]}","height,strong",今日はいい日です 12 | 9,25,300,Dwi,130.12,1,"{""EF"":78,""CF"":[90,12]}",,"Hari ini adalah hari yang baik 13 | Besok juga hari yang baik" 14 | 10,25,400,Bảo,131.23,1,"[""BC"",{""AT"":34}]","thin,good", 15 | 11,26,400,민준,132.34,0,"[""FG"",{""AG"":34}]","hot,thin,good",오늘은 좋은 날이다 16 | 12,26,400,ดาว,133.456,0,,, -------------------------------------------------------------------------------- /release/docs/hx/highlighter.css: -------------------------------------------------------------------------------- 1 | /** 2 | Code Highlighting 3 | **/ 4 | html pre, 5 | html pre code { 6 | font-family: consolas, monospace; 7 | white-space: pre; 8 | overflow-x: auto; 9 | } 10 | 11 | code { 12 | color: #333; 13 | } 14 | 15 | code a { 16 | color: #08c; 17 | } 18 | 19 | pre { 20 | color: #333; 21 | margin: 15px 0; 22 | padding: 0.5em; 23 | } 24 | 25 | pre .type { 26 | color: #0086b3; 27 | } 28 | 29 | pre .kwd { 30 | color: #00a; 31 | } 32 | 33 | pre .val { 34 | color: #44a; 35 | } 36 | 37 | pre .str, 38 | div.pre .str, 39 | pre .str .kwd, 40 | pre .str .val, 41 | pre .str .type { 42 | color: #a00; 43 | } 44 | 45 | pre .cmt { 46 | color: #008800; 47 | color: #998; 48 | font-style: italic; 49 | } 50 | 51 | /* Make sure keywords inside comments are not highlighted*/ 52 | pre .cmt .kwd, 53 | pre .cmt .str, 54 | pre .cmt .val, 55 | pre .cmt .type { 56 | color: #998; 57 | } 58 | 59 | .last-modified { 60 | color: #999; 61 | } 62 | 63 | .semantic { 64 | display: none; 65 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 amin2312 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /release/docs/hx/nav.js: -------------------------------------------------------------------------------- 1 | var navContent=''; -------------------------------------------------------------------------------- /src/java/org/json/JSONException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.json; 18 | 19 | // Note: this class was written without inspecting the non-free org.json sourcecode. 20 | 21 | /** 22 | * Thrown to indicate a problem with the JSON API. Such problems include: 23 | * 31 | * 32 | *

Although this is a checked exception, it is rarely recoverable. Most 33 | * callers should simply wrap this exception in an unchecked exception and 34 | * rethrow: 35 | *

  public JSONArray toJSONObject() {
36 |  *     try {
37 |  *         JSONObject result = new JSONObject();
38 |  *         ...
39 |  *     } catch (JSONException e) {
40 |  *         throw new RuntimeException(e);
41 |  *     }
42 |  * }
43 | */ 44 | public class JSONException extends Exception { 45 | 46 | public JSONException(String s) { 47 | super(s); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /release/docs/hx/highlighter.js: -------------------------------------------------------------------------------- 1 | // highlighter adapted/modified from code.haxe.org 2 | (function (console) { "use strict"; 3 | var EReg = function(r,opt) { 4 | opt = opt.split("u").join(""); 5 | this.r = new RegExp(r,opt); 6 | }; 7 | EReg.prototype = { 8 | replace: function(s,by) { 9 | return s.replace(this.r,by); 10 | } 11 | }; 12 | var Highlighter = function() { }; 13 | Highlighter.main = function() { 14 | var _g = 0; 15 | var _g1 = window.document.body.querySelectorAll("pre code"); 16 | while(_g < _g1.length) { 17 | var el = _g1[_g]; 18 | ++_g; 19 | if(!Highlighter.hasClass(el,"highlighted")) { 20 | el.innerHTML = Highlighter.syntaxHighlight(el.innerHTML); 21 | el.className += " highlighted"; 22 | } 23 | } 24 | }; 25 | Highlighter.hasClass = function(el,className) { 26 | return el.className.indexOf(className) != -1; 27 | }; 28 | Highlighter.syntaxHighlight = function(html) { 29 | var kwds = ["abstract","trace","break","case","cast","class","continue","default","do","dynamic","else","enum","extends","extern","for","function","if","implements","import","in","inline","interface","macro","new","override","package","private","public","return","static","switch","throw","try","typedef","untyped","using","var","while"]; 30 | var kwds1 = new EReg("\\b(" + kwds.join("|") + ")\\b","g"); 31 | var vals = ["null","true","false","this"]; 32 | var vals1 = new EReg("\\b(" + vals.join("|") + ")\\b","g"); 33 | var types = new EReg("\\b([A-Z][a-zA-Z0-9]*)\\b","g"); 34 | html = kwds1.replace(html,"$1"); 35 | html = vals1.replace(html,"$1"); 36 | html = types.replace(html,"$1"); 37 | html = new EReg("(\"[^\"]*\")","g").replace(html,"$1"); 38 | html = new EReg("(//.+?)(\n|$)","g").replace(html,"$1$2"); 39 | html = new EReg("(/\\*\\*?(.|\n)+?\\*?\\*/)","g").replace(html,"$1"); 40 | return html; 41 | }; 42 | Highlighter.main(); 43 | })(typeof console != "undefined" ? console : {log:function(){}}); 44 | -------------------------------------------------------------------------------- /release/docs/hx/404.html: -------------------------------------------------------------------------------- 1 | File not found - ACsv library

404 Page not found

Page not found, sorry.

-------------------------------------------------------------------------------- /release/js/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 100 | 101 | 102 |
103 | 104 |
ACsv javascript code (via Haxe)
105 |
106 |
107 |
108 |





109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /release/ts/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 100 | 101 | 102 |
103 | 104 |
ACsv typescript code (with js library)
105 |
106 |
107 |
108 |





109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /release/docs/hx/acsv/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | acsv - ACsv library

acsv

..
Field
  1. Copyright (c) 2022 amin2312
  2. Version 1.0.0
  3. MIT License
10 |

CSV head field.

Table
  1. Copyright (c) 2022 amin2312
  2. Version 1.0.0
  3. MIT License
11 |

ACsv is a easy, fast and powerful csv parse library.

-------------------------------------------------------------------------------- /languages/中文.md: -------------------------------------------------------------------------------- 1 | ACsv Library 2 | ================ 3 | [![](https://img.shields.io/badge/support-haxe-blue)](https://github.com/amin2312/ACsv/tree/main/src/haxe) 4 | [![](https://img.shields.io/badge/support-javascript-blue)](https://github.com/amin2312/ACsv/tree/main/src/javascript) 5 | [![](https://img.shields.io/badge/support-typescript-blue)](https://github.com/amin2312/ACsv/tree/main/src/typescript) 6 | [![](https://img.shields.io/badge/support-php-blue)](https://github.com/amin2312/ACsv/tree/main/src/php) 7 | [![](https://img.shields.io/badge/support-java-blue)](https://github.com/amin2312/ACsv/tree/main/src/java) 8 | [![](https://img.shields.io/badge/support-python-blue)](https://github.com/amin2312/ACsv/tree/main/src/python) 9 | [![](https://img.shields.io/badge/support-c%23-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 10 | [![](https://img.shields.io/badge/support-golang-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 11 | [![](https://img.shields.io/badge/csv-parsing-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 12 | [![](https://img.shields.io/badge/csv-standard-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 13 | [![](https://img.shields.io/badge/csv-enhanced-red)](https://github.com/amin2312/ACsv/tree/main/src/python) 14 | 15 | **ACsv** 是一个易用, 多平台和强大的 **csv解析库**. 16 | 17 | 功能列表: 18 | * **多平台** - 提供 **haxe**, **js**, **ts**, **php**, **java**, **python**, **c#** , **golang** 版本 19 | * **标准** - 支持标准csv格式 (RFC 4180) 20 | * **易用** - 提供例子, 示范和文档 21 | * **快速** - 优化代码以实现高性能,它可以在旧设备中轻松运行 22 | * **强大** - 支持 **增强版** csv 格式, 详情请见[英文说明](../README.md) 23 | 24 | 例子 25 | ---------------- 26 | ```javascript 27 | // enhanced_csv_content 28 | //---------------------------------------------------------------- 29 | //| id:int | name:string | age:int | weight:number | tags:json | 30 | //|--------------------------------------------------------------| 31 | //| 1 | John | 20 | 60.1 | ["cool"] | 32 | //| 2 | Mary | 20 | 60.2 | ["thin"] | 33 | //| 3 | Tom | 18 | 60.3 | ["young"] | 34 | //---------------------------------------------------------------- 35 | 36 | var table = acsv.Table.Parse(enhanced_csv_content); 37 | table.selectWhenE(1, 3).toFirstObj(); 38 | // {id: 3, name: "Tom", age: 18, weight: 60.3, tags: ["young"] } 39 | 40 | table.selectWhenE(0, 20, 2).toObjs(); 41 | // [ 42 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] }, 43 | // {id: 2, name: "Mary", age: 20, weight: 60.2, tags: ["thin"] } 44 | // ] 45 | 46 | // Method Chaining Usage 47 | table.selectWhenE(0, 20, 2).selectWhenL(0, false, 60.2).toObjs(); 48 | // [ 49 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] } 50 | // ] 51 | ``` 52 | 53 | 示范 54 | ---------------- 55 | * [Javascript demo - via Haxe code to compile](https://amin2312.github.io/ACsv/release/js/demo.html) 56 | * [Javascript demo - via Typescript code to compile](https://amin2312.github.io/ACsv/release/ts/demo.html) 57 | 58 | 文档 59 | ---------------- 60 | [Online docs - via dox](https://amin2312.github.io/ACsv/release/docs/hx/index.html) 61 | 62 | 其他 63 | ---------------- 64 | ***⭐ 如果你喜欢这个项目,请加个星*** 65 | ***⭐ [english version](../README.md)*** -------------------------------------------------------------------------------- /release/docs/hx/Dynamic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Dynamic - ACsv library

Dynamic is a special type which is compatible with all other types.

10 |

Use of Dynamic should be minimized as it prevents several compiler 11 | checks and optimizations. See Any type for a safer alternative for 12 | representing values of any type.

See:

-------------------------------------------------------------------------------- /languages/日本語.md: -------------------------------------------------------------------------------- 1 | ACsv Library 2 | ================ 3 | [![](https://img.shields.io/badge/support-haxe-blue)](https://github.com/amin2312/ACsv/tree/main/src/haxe) 4 | [![](https://img.shields.io/badge/support-javascript-blue)](https://github.com/amin2312/ACsv/tree/main/src/javascript) 5 | [![](https://img.shields.io/badge/support-typescript-blue)](https://github.com/amin2312/ACsv/tree/main/src/typescript) 6 | [![](https://img.shields.io/badge/support-php-blue)](https://github.com/amin2312/ACsv/tree/main/src/php) 7 | [![](https://img.shields.io/badge/support-java-blue)](https://github.com/amin2312/ACsv/tree/main/src/java) 8 | [![](https://img.shields.io/badge/support-python-blue)](https://github.com/amin2312/ACsv/tree/main/src/python) 9 | [![](https://img.shields.io/badge/support-c%23-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 10 | [![](https://img.shields.io/badge/support-golang-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 11 | [![](https://img.shields.io/badge/csv-parsing-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 12 | [![](https://img.shields.io/badge/csv-standard-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 13 | [![](https://img.shields.io/badge/csv-enhanced-red)](https://github.com/amin2312/ACsv/tree/main/src/python) 14 | 15 | **ACsv** は**"csv解析ライブラリ"**です - 簡単で、マルチプラットフォームで、強力です 16 | 17 | 機能: 18 | * **マルチプラットフォーム** - **haxe**, **js**, **ts**, **php**, **java**, **python**, **c#** , **golang** バージョンを提供する 19 | * **標準** - 標準csv形式をサポートします (RFC 4180) 20 | * **使いやすい** - 例、デモ、ドキュメントを提供する 21 | * **速いスピード** - 高性能のために最適化されたコード、それは古いデバイスで簡単に動作することができます 22 | * **強力** - **"拡張"** csv形式をサポートします, [Engilshページ](../README.md)で詳細を参照してください 23 | 24 | 例 25 | ---------------- 26 | ```javascript 27 | // enhanced_csv_content 28 | //---------------------------------------------------------------- 29 | //| id:int | name:string | age:int | weight:number | tags:json | 30 | //|--------------------------------------------------------------| 31 | //| 1 | John | 20 | 60.1 | ["cool"] | 32 | //| 2 | Mary | 20 | 60.2 | ["thin"] | 33 | //| 3 | Tom | 18 | 60.3 | ["young"] | 34 | //---------------------------------------------------------------- 35 | 36 | var table = acsv.Table.Parse(enhanced_csv_content); 37 | table.selectWhenE(1, 3).toFirstObj(); 38 | // {id: 3, name: "Tom", age: 18, weight: 60.3, tags: ["young"] } 39 | 40 | table.selectWhenE(0, 20, 2).toObjs(); 41 | // [ 42 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] }, 43 | // {id: 2, name: "Mary", age: 20, weight: 60.2, tags: ["thin"] } 44 | // ] 45 | 46 | // Method Chaining Usage 47 | table.selectWhenE(0, 20, 2).selectWhenL(0, false, 60.2).toObjs(); 48 | // [ 49 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] } 50 | // ] 51 | ``` 52 | 53 | デモ 54 | ---------------- 55 | * [Javascript demo - via Haxe code to compile](https://amin2312.github.io/ACsv/release/js/demo.html) 56 | * [Javascript demo - via Typescript code to compile](https://amin2312.github.io/ACsv/release/ts/demo.html) 57 | 58 | ドキュメント 59 | ---------------- 60 | [Online docs - via dox](https://amin2312.github.io/ACsv/release/docs/hx/index.html) 61 | 62 | その他 63 | ---------------- 64 | ***⭐ このプロジェクトが気に入ったら、星を追加してください*** 65 | ***⭐ [english version](../README.md)*** -------------------------------------------------------------------------------- /languages/tiếng_việt.md: -------------------------------------------------------------------------------- 1 | ACsv Library 2 | ================ 3 | [![](https://img.shields.io/badge/support-haxe-blue)](https://github.com/amin2312/ACsv/tree/main/src/haxe) 4 | [![](https://img.shields.io/badge/support-javascript-blue)](https://github.com/amin2312/ACsv/tree/main/src/javascript) 5 | [![](https://img.shields.io/badge/support-typescript-blue)](https://github.com/amin2312/ACsv/tree/main/src/typescript) 6 | [![](https://img.shields.io/badge/support-php-blue)](https://github.com/amin2312/ACsv/tree/main/src/php) 7 | [![](https://img.shields.io/badge/support-java-blue)](https://github.com/amin2312/ACsv/tree/main/src/java) 8 | [![](https://img.shields.io/badge/support-python-blue)](https://github.com/amin2312/ACsv/tree/main/src/python) 9 | [![](https://img.shields.io/badge/support-c%23-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 10 | [![](https://img.shields.io/badge/support-golang-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 11 | [![](https://img.shields.io/badge/csv-parsing-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 12 | [![](https://img.shields.io/badge/csv-standard-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 13 | [![](https://img.shields.io/badge/csv-enhanced-red)](https://github.com/amin2312/ACsv/tree/main/src/python) 14 | 15 | **ACsv** là một **"csv parsing library"** dễ dàng, đa nền tảng và mạnh mẽ. 16 | 17 | Các tính năng: 18 | * **đa nền tảng** - cung cấp **haxe**, **js**, **ts**, **php**, **java**, **python**, **c#** , **golang** phiên bản 19 | * **tiêu chuẩn** - hỗ trợ csv tiêu chuẩn định dạng (RFC 4180) 20 | * **dễ sử dụng** - cung cấp ví dụ, bản trình diễn và tài liệu 21 | * **tốc độ nhanh** - mã được tối ưu hóa cho hiệu suất cao, nó có thể hoạt động dễ dàng trong thiết bị cũ hơn 22 | * **mạnh mẽ** - hỗ trợ **"enhanced"** csv định dạng, xem chi tiết trong [trang Engilsh](../README.md) 23 | 24 | ví dụ 25 | ---------------- 26 | ```javascript 27 | // enhanced_csv_content 28 | //---------------------------------------------------------------- 29 | //| id:int | name:string | age:int | weight:number | tags:json | 30 | //|--------------------------------------------------------------| 31 | //| 1 | John | 20 | 60.1 | ["cool"] | 32 | //| 2 | Mary | 20 | 60.2 | ["thin"] | 33 | //| 3 | Tom | 18 | 60.3 | ["young"] | 34 | //---------------------------------------------------------------- 35 | 36 | var table = acsv.Table.Parse(enhanced_csv_content); 37 | table.selectWhenE(1, 3).toFirstObj(); 38 | // {id: 3, name: "Tom", age: 18, weight: 60.3, tags: ["young"] } 39 | 40 | table.selectWhenE(0, 20, 2).toObjs(); 41 | // [ 42 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] }, 43 | // {id: 2, name: "Mary", age: 20, weight: 60.2, tags: ["thin"] } 44 | // ] 45 | 46 | // Method Chaining Usage 47 | table.selectWhenE(0, 20, 2).selectWhenL(0, false, 60.2).toObjs(); 48 | // [ 49 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] } 50 | // ] 51 | ``` 52 | 53 | bản trình diễn 54 | ---------------- 55 | * [Javascript demo - via Haxe code to compile](https://amin2312.github.io/ACsv/release/js/demo.html) 56 | * [Javascript demo - via Typescript code to compile](https://amin2312.github.io/ACsv/release/ts/demo.html) 57 | 58 | tài liệu 59 | ---------------- 60 | [Online docs - via dox](https://amin2312.github.io/ACsv/release/docs/hx/index.html) 61 | 62 | khác 63 | ---------------- 64 | ***⭐ Nếu bạn thích dự án này, hãy thêm một ngôi sao*** 65 | ***⭐ [english version](../README.md)*** -------------------------------------------------------------------------------- /release/docs/hx/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | top level - ACsv library

top level

acsv
Array

An Array is a storage for values. You can access it using indexes or 10 | with its API.

Dynamic

Dynamic is a special type which is compatible with all other types.

Float

The standard Float type, this is a double-precision IEEE 64bit float.

Int

The standard Int type. Its precision depends on the platform.

String

The basic String class.

-------------------------------------------------------------------------------- /languages/indonesia.md: -------------------------------------------------------------------------------- 1 | ACsv Library 2 | ================ 3 | [![](https://img.shields.io/badge/support-haxe-blue)](https://github.com/amin2312/ACsv/tree/main/src/haxe) 4 | [![](https://img.shields.io/badge/support-javascript-blue)](https://github.com/amin2312/ACsv/tree/main/src/javascript) 5 | [![](https://img.shields.io/badge/support-typescript-blue)](https://github.com/amin2312/ACsv/tree/main/src/typescript) 6 | [![](https://img.shields.io/badge/support-php-blue)](https://github.com/amin2312/ACsv/tree/main/src/php) 7 | [![](https://img.shields.io/badge/support-java-blue)](https://github.com/amin2312/ACsv/tree/main/src/java) 8 | [![](https://img.shields.io/badge/support-python-blue)](https://github.com/amin2312/ACsv/tree/main/src/python) 9 | [![](https://img.shields.io/badge/support-c%23-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 10 | [![](https://img.shields.io/badge/support-golang-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 11 | [![](https://img.shields.io/badge/csv-parsing-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 12 | [![](https://img.shields.io/badge/csv-standard-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 13 | [![](https://img.shields.io/badge/csv-enhanced-red)](https://github.com/amin2312/ACsv/tree/main/src/python) 14 | 15 | **ACsv** adalah **"cse parsing perpustakaan"** yang mudah, multi-platform dan kuat. 16 | 17 | Fitur: 18 | * **multi-platform** - sediakan **haxe**, **js**, **ts**, **php**, **java**, **python**, **c#** , **golang** versi 19 | * **standar** - mendukung csv standar format (RFC 4180) 20 | * **mudah digunakan** - sediakan contoh, demo, dan dokumentasi 21 | * **kecepatan cepat** - kode yang dioptimalkan untuk kinerja tinggi, dapat bekerja dengan mudah di perangkat yang lebih lama 22 | * **kuat** - mendukung **"enhanced"** csv format, lihat detailnya di [halaman Inggris](../README.md) 23 | 24 | contoh 25 | ---------------- 26 | ```javascript 27 | // enhanced_csv_content 28 | //---------------------------------------------------------------- 29 | //| id:int | name:string | age:int | weight:number | tags:json | 30 | //|--------------------------------------------------------------| 31 | //| 1 | John | 20 | 60.1 | ["cool"] | 32 | //| 2 | Mary | 20 | 60.2 | ["thin"] | 33 | //| 3 | Tom | 18 | 60.3 | ["young"] | 34 | //---------------------------------------------------------------- 35 | 36 | var table = acsv.Table.Parse(enhanced_csv_content); 37 | table.selectWhenE(1, 3).toFirstObj(); 38 | // {id: 3, name: "Tom", age: 18, weight: 60.3, tags: ["young"] } 39 | 40 | table.selectWhenE(0, 20, 2).toObjs(); 41 | // [ 42 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] }, 43 | // {id: 2, name: "Mary", age: 20, weight: 60.2, tags: ["thin"] } 44 | // ] 45 | 46 | // Method Chaining Usage 47 | table.selectWhenE(0, 20, 2).selectWhenL(0, false, 60.2).toObjs(); 48 | // [ 49 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] } 50 | // ] 51 | ``` 52 | 53 | demo 54 | ---------------- 55 | * [Javascript demo - via Haxe code to compile](https://amin2312.github.io/ACsv/release/js/demo.html) 56 | * [Javascript demo - via Typescript code to compile](https://amin2312.github.io/ACsv/release/ts/demo.html) 57 | 58 | dokumentasi 59 | ---------------- 60 | [Online docs - via dox](https://amin2312.github.io/ACsv/release/docs/hx/index.html) 61 | 62 | yang lain 63 | ---------------- 64 | ***⭐ Jika Anda menyukai proyek ini, silakan tambahkan bintang*** 65 | ***⭐ [english version](../README.md)*** -------------------------------------------------------------------------------- /languages/portugués.md: -------------------------------------------------------------------------------- 1 | ACsv Library 2 | ================ 3 | [![](https://img.shields.io/badge/support-haxe-blue)](https://github.com/amin2312/ACsv/tree/main/src/haxe) 4 | [![](https://img.shields.io/badge/support-javascript-blue)](https://github.com/amin2312/ACsv/tree/main/src/javascript) 5 | [![](https://img.shields.io/badge/support-typescript-blue)](https://github.com/amin2312/ACsv/tree/main/src/typescript) 6 | [![](https://img.shields.io/badge/support-php-blue)](https://github.com/amin2312/ACsv/tree/main/src/php) 7 | [![](https://img.shields.io/badge/support-java-blue)](https://github.com/amin2312/ACsv/tree/main/src/java) 8 | [![](https://img.shields.io/badge/support-python-blue)](https://github.com/amin2312/ACsv/tree/main/src/python) 9 | [![](https://img.shields.io/badge/support-c%23-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 10 | [![](https://img.shields.io/badge/support-golang-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 11 | [![](https://img.shields.io/badge/csv-parsing-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 12 | [![](https://img.shields.io/badge/csv-standard-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 13 | [![](https://img.shields.io/badge/csv-enhanced-red)](https://github.com/amin2312/ACsv/tree/main/src/python) 14 | 15 | **ACsv** é uma **"csv parsing livraria"** fácil, multi-plataforma y poderosa. 16 | 17 | As características 18 | * **multi-plataforma** - forneça **haxe**, **js**, **ts**, **php**, **java**, **python**, **c#** , **golang** versão 19 | * **estándar** - suporta o csv padrão formato (RFC 4180) 20 | * **fácil de usar** - forneça o exemplo, demonstração e documentação 21 | * **rápida velocidad** - código otimizado para alto desempenho, pode funcionar facilmente em dispositivos mais antigos 22 | * **poderosa** - suporta **"enhanced"** csv formato, veja detalhes na [página em inglês](../README.md) 23 | 24 | exemplo 25 | ---------------- 26 | ```javascript 27 | // enhanced_csv_content 28 | //---------------------------------------------------------------- 29 | //| id:int | name:string | age:int | weight:number | tags:json | 30 | //|--------------------------------------------------------------| 31 | //| 1 | John | 20 | 60.1 | ["cool"] | 32 | //| 2 | Mary | 20 | 60.2 | ["thin"] | 33 | //| 3 | Tom | 18 | 60.3 | ["young"] | 34 | //---------------------------------------------------------------- 35 | 36 | var table = acsv.Table.Parse(enhanced_csv_content); 37 | table.selectWhenE(1, 3).toFirstObj(); 38 | // {id: 3, name: "Tom", age: 18, weight: 60.3, tags: ["young"] } 39 | 40 | table.selectWhenE(0, 20, 2).toObjs(); 41 | // [ 42 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] }, 43 | // {id: 2, name: "Mary", age: 20, weight: 60.2, tags: ["thin"] } 44 | // ] 45 | 46 | // Method Chaining Usage 47 | table.selectWhenE(0, 20, 2).selectWhenL(0, false, 60.2).toObjs(); 48 | // [ 49 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] } 50 | // ] 51 | ``` 52 | 53 | demonstração 54 | ---------------- 55 | * [Javascript demo - via Haxe code to compile](https://amin2312.github.io/ACsv/release/js/demo.html) 56 | * [Javascript demo - via Typescript code to compile](https://amin2312.github.io/ACsv/release/ts/demo.html) 57 | 58 | documentação 59 | ---------------- 60 | [Online docs - via dox](https://amin2312.github.io/ACsv/release/docs/hx/index.html) 61 | 62 | outros 63 | ---------------- 64 | ***⭐ Se você gosta deste projeto, por favor, adicione uma estrela*** 65 | ***⭐ [english version](../README.md)*** -------------------------------------------------------------------------------- /languages/русский.md: -------------------------------------------------------------------------------- 1 | ACsv Library 2 | ================ 3 | [![](https://img.shields.io/badge/support-haxe-blue)](https://github.com/amin2312/ACsv/tree/main/src/haxe) 4 | [![](https://img.shields.io/badge/support-javascript-blue)](https://github.com/amin2312/ACsv/tree/main/src/javascript) 5 | [![](https://img.shields.io/badge/support-typescript-blue)](https://github.com/amin2312/ACsv/tree/main/src/typescript) 6 | [![](https://img.shields.io/badge/support-php-blue)](https://github.com/amin2312/ACsv/tree/main/src/php) 7 | [![](https://img.shields.io/badge/support-java-blue)](https://github.com/amin2312/ACsv/tree/main/src/java) 8 | [![](https://img.shields.io/badge/support-python-blue)](https://github.com/amin2312/ACsv/tree/main/src/python) 9 | [![](https://img.shields.io/badge/support-c%23-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 10 | [![](https://img.shields.io/badge/support-golang-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 11 | [![](https://img.shields.io/badge/csv-parsing-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 12 | [![](https://img.shields.io/badge/csv-standard-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 13 | [![](https://img.shields.io/badge/csv-enhanced-red)](https://github.com/amin2312/ACsv/tree/main/src/python) 14 | 15 | **ACsv** это простая, многоплатформенная и мощная **"csv parsing библиотека"**. 16 | 17 | Особенности: 18 | * **многоплатформенная** - предоставьте **haxe**, **js**, **ts**, **php**, **java**, **python**, **c#** , **golang** версию 19 | * **стандартный** - поддержка csv стандартного формата (RFC 4180) 20 | * **простая** - предоставьте пример, демонстрацию и документацию 21 | * **высокая скорость** - оптимизированный код для высокой производительности, он может легко работать на старых устройствах 22 | * **мощная** - поддержка **"enhanced"** csv формата, см. подробности на [английской странице](../README.md) 23 | 24 | пример 25 | ---------------- 26 | ```javascript 27 | // enhanced_csv_content 28 | //---------------------------------------------------------------- 29 | //| id:int | name:string | age:int | weight:number | tags:json | 30 | //|--------------------------------------------------------------| 31 | //| 1 | John | 20 | 60.1 | ["cool"] | 32 | //| 2 | Mary | 20 | 60.2 | ["thin"] | 33 | //| 3 | Tom | 18 | 60.3 | ["young"] | 34 | //---------------------------------------------------------------- 35 | 36 | var table = acsv.Table.Parse(enhanced_csv_content); 37 | table.selectWhenE(1, 3).toFirstObj(); 38 | // {id: 3, name: "Tom", age: 18, weight: 60.3, tags: ["young"] } 39 | 40 | table.selectWhenE(0, 20, 2).toObjs(); 41 | // [ 42 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] }, 43 | // {id: 2, name: "Mary", age: 20, weight: 60.2, tags: ["thin"] } 44 | // ] 45 | 46 | // Method Chaining Usage 47 | table.selectWhenE(0, 20, 2).selectWhenL(0, false, 60.2).toObjs(); 48 | // [ 49 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] } 50 | // ] 51 | ``` 52 | 53 | демонстрацию 54 | ---------------- 55 | * [Javascript demo - via Haxe code to compile](https://amin2312.github.io/ACsv/release/js/demo.html) 56 | * [Javascript demo - via Typescript code to compile](https://amin2312.github.io/ACsv/release/ts/demo.html) 57 | 58 | документацию 59 | ---------------- 60 | [Online docs - via dox](https://amin2312.github.io/ACsv/release/docs/hx/index.html) 61 | 62 | другие 63 | ---------------- 64 | ***⭐ Если вам нравится этот проект, пожалуйста, добавьте звезду*** 65 | ***⭐ [english version](../README.md)*** -------------------------------------------------------------------------------- /languages/español.md: -------------------------------------------------------------------------------- 1 | ACsv Library 2 | ================ 3 | [![](https://img.shields.io/badge/support-haxe-blue)](https://github.com/amin2312/ACsv/tree/main/src/haxe) 4 | [![](https://img.shields.io/badge/support-javascript-blue)](https://github.com/amin2312/ACsv/tree/main/src/javascript) 5 | [![](https://img.shields.io/badge/support-typescript-blue)](https://github.com/amin2312/ACsv/tree/main/src/typescript) 6 | [![](https://img.shields.io/badge/support-php-blue)](https://github.com/amin2312/ACsv/tree/main/src/php) 7 | [![](https://img.shields.io/badge/support-java-blue)](https://github.com/amin2312/ACsv/tree/main/src/java) 8 | [![](https://img.shields.io/badge/support-python-blue)](https://github.com/amin2312/ACsv/tree/main/src/python) 9 | [![](https://img.shields.io/badge/support-c%23-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 10 | [![](https://img.shields.io/badge/support-golang-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 11 | [![](https://img.shields.io/badge/csv-parsing-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 12 | [![](https://img.shields.io/badge/csv-standard-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 13 | [![](https://img.shields.io/badge/csv-enhanced-red)](https://github.com/amin2312/ACsv/tree/main/src/python) 14 | 15 | **ACsv** es una **"csv parsing librería"** fácil, multi-plataforma y poderosa. 16 | 17 | Las características: 18 | * **multi-plataforma** - proporcionar **haxe**, **js**, **ts**, **php**, **java**, **python**, **c#** , **golang** versión 19 | * **estándar** - compatible con csv estándar formato (RFC 4180) 20 | * **fácil de usar** - proporcionar el ejemplo, la demostración y la documentación 21 | * **rápida velocidad** - código optimizado para alto rendimiento, puede funcionar fácilmente en dispositivos más antiguos 22 | * **poderosa** - compatible con **"enhanced"** csv formato, ver detalles en [pagina en ingles](../README.md) 23 | 24 | ejemplo 25 | ---------------- 26 | ```javascript 27 | // enhanced_csv_content 28 | //---------------------------------------------------------------- 29 | //| id:int | name:string | age:int | weight:number | tags:json | 30 | //|--------------------------------------------------------------| 31 | //| 1 | John | 20 | 60.1 | ["cool"] | 32 | //| 2 | Mary | 20 | 60.2 | ["thin"] | 33 | //| 3 | Tom | 18 | 60.3 | ["young"] | 34 | //---------------------------------------------------------------- 35 | 36 | var table = acsv.Table.Parse(enhanced_csv_content); 37 | table.selectWhenE(1, 3).toFirstObj(); 38 | // {id: 3, name: "Tom", age: 18, weight: 60.3, tags: ["young"] } 39 | 40 | table.selectWhenE(0, 20, 2).toObjs(); 41 | // [ 42 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] }, 43 | // {id: 2, name: "Mary", age: 20, weight: 60.2, tags: ["thin"] } 44 | // ] 45 | 46 | // Method Chaining Usage 47 | table.selectWhenE(0, 20, 2).selectWhenL(0, false, 60.2).toObjs(); 48 | // [ 49 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] } 50 | // ] 51 | ``` 52 | 53 | demostración 54 | ---------------- 55 | * [Javascript demo - via Haxe code to compile](https://amin2312.github.io/ACsv/release/js/demo.html) 56 | * [Javascript demo - via Typescript code to compile](https://amin2312.github.io/ACsv/release/ts/demo.html) 57 | 58 | documentación 59 | ---------------- 60 | [Online docs - via dox](https://amin2312.github.io/ACsv/release/docs/hx/index.html) 61 | 62 | otros 63 | ---------------- 64 | ***⭐ Si te gusta este proyecto, por favor agrega una estrella*** 65 | ***⭐ [english version](../README.md)*** -------------------------------------------------------------------------------- /languages/français.md: -------------------------------------------------------------------------------- 1 | ACsv Library 2 | ================ 3 | [![](https://img.shields.io/badge/support-haxe-blue)](https://github.com/amin2312/ACsv/tree/main/src/haxe) 4 | [![](https://img.shields.io/badge/support-javascript-blue)](https://github.com/amin2312/ACsv/tree/main/src/javascript) 5 | [![](https://img.shields.io/badge/support-typescript-blue)](https://github.com/amin2312/ACsv/tree/main/src/typescript) 6 | [![](https://img.shields.io/badge/support-php-blue)](https://github.com/amin2312/ACsv/tree/main/src/php) 7 | [![](https://img.shields.io/badge/support-java-blue)](https://github.com/amin2312/ACsv/tree/main/src/java) 8 | [![](https://img.shields.io/badge/support-python-blue)](https://github.com/amin2312/ACsv/tree/main/src/python) 9 | [![](https://img.shields.io/badge/support-c%23-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 10 | [![](https://img.shields.io/badge/support-golang-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 11 | [![](https://img.shields.io/badge/csv-parsing-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 12 | [![](https://img.shields.io/badge/csv-standard-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 13 | [![](https://img.shields.io/badge/csv-enhanced-red)](https://github.com/amin2312/ACsv/tree/main/src/python) 14 | 15 | **ACsv** est une **"csv parsing livraria"** facile, multi-plateforme et puissante. 16 | 17 | Les caractéristiques: 18 | * **multi-plateforme** - fournir **haxe**, **js**, **ts**, **php**, **java**, **python**, **c#** , **golang** version 19 | * **standard** - prend en charge csv standard format (RFC 4180) 20 | * **facile à utiliser** - fournir exemple, démonstration et documentation 21 | * **vitesse rapide** - code optimisé pour des performances élevées, il peut fonctionner facilement dans un appareil plus ancien 22 | * **puissante** - prend en charge le **"enhanced"** csv format, voir les détails sur [page en anglais](../README.md) 23 | 24 | exemple 25 | ---------------- 26 | ```javascript 27 | // enhanced_csv_content 28 | //---------------------------------------------------------------- 29 | //| id:int | name:string | age:int | weight:number | tags:json | 30 | //|--------------------------------------------------------------| 31 | //| 1 | John | 20 | 60.1 | ["cool"] | 32 | //| 2 | Mary | 20 | 60.2 | ["thin"] | 33 | //| 3 | Tom | 18 | 60.3 | ["young"] | 34 | //---------------------------------------------------------------- 35 | 36 | var table = acsv.Table.Parse(enhanced_csv_content); 37 | table.selectWhenE(1, 3).toFirstObj(); 38 | // {id: 3, name: "Tom", age: 18, weight: 60.3, tags: ["young"] } 39 | 40 | table.selectWhenE(0, 20, 2).toObjs(); 41 | // [ 42 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] }, 43 | // {id: 2, name: "Mary", age: 20, weight: 60.2, tags: ["thin"] } 44 | // ] 45 | 46 | // Method Chaining Usage 47 | table.selectWhenE(0, 20, 2).selectWhenL(0, false, 60.2).toObjs(); 48 | // [ 49 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] } 50 | // ] 51 | ``` 52 | 53 | démonstration 54 | ---------------- 55 | * [Javascript demo - via Haxe code to compile](https://amin2312.github.io/ACsv/release/js/demo.html) 56 | * [Javascript demo - via Typescript code to compile](https://amin2312.github.io/ACsv/release/ts/demo.html) 57 | 58 | documentation 59 | ---------------- 60 | [Online docs - via dox](https://amin2312.github.io/ACsv/release/docs/hx/index.html) 61 | 62 | autres 63 | ---------------- 64 | ***⭐ Si vous aimez ce projet, veuillez ajouter une étoile*** 65 | ***⭐ [english version](../README.md)*** -------------------------------------------------------------------------------- /release/docs/hx/Float.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Float - ACsv library

The standard Float type, this is a double-precision IEEE 64bit float.

10 |

On static targets, null cannot be assigned to Float. If this is necessary, 11 | Null<Float> can be used instead.

12 |

Std.int converts a Float to an Int, rounded towards 0. 13 | Std.parseFloat converts a String to a Float.

See:

-------------------------------------------------------------------------------- /release/docs/hx/Int.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Int - ACsv library

The standard Int type. Its precision depends on the platform.

10 |

On static targets, null cannot be assigned to Int. If this is necessary, 11 | Null<Int> can be used instead.

12 |

Std.int converts a Float to an Int, rounded towards 0. 13 | Std.parseInt converts a String to an Int.

See:

-------------------------------------------------------------------------------- /release/docs/hx/acsv/Field.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | acsv.Field - ACsv library
  1. Copyright (c) 2022 amin2312
  2. Version 1.0.0
  3. MIT License
11 |

CSV head field.

Variables

fullName:String

Full Name.

-------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ACsv Library 2 | ================ 3 | [![](https://img.shields.io/badge/support-haxe-blue)](https://github.com/amin2312/ACsv/tree/main/src/haxe) 4 | [![](https://img.shields.io/badge/support-javascript-blue)](https://github.com/amin2312/ACsv/tree/main/src/javascript) 5 | [![](https://img.shields.io/badge/support-typescript-blue)](https://github.com/amin2312/ACsv/tree/main/src/typescript) 6 | [![](https://img.shields.io/badge/support-php-blue)](https://github.com/amin2312/ACsv/tree/main/src/php) 7 | [![](https://img.shields.io/badge/support-java-blue)](https://github.com/amin2312/ACsv/tree/main/src/java) 8 | [![](https://img.shields.io/badge/support-python-blue)](https://github.com/amin2312/ACsv/tree/main/src/python) 9 | [![](https://img.shields.io/badge/support-c%23-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 10 | [![](https://img.shields.io/badge/support-golang-blue)](https://github.com/amin2312/ACsv/tree/main/src/csharp) 11 | [![](https://img.shields.io/badge/csv-parsing-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 12 | [![](https://img.shields.io/badge/csv-standard-green)](https://github.com/amin2312/ACsv/tree/main/src/python) 13 | [![](https://img.shields.io/badge/csv-enhanced-red)](https://github.com/amin2312/ACsv/tree/main/src/python) 14 | 15 | | **[Español](languages/espa%C3%B1ol.md)** | **[Portugués](languages/portugués.md)** | **[Français](languages/fran%C3%A7ais.md)** | **[Русский](languages/русский.md)** | **[中文](languages/中文.md)** | **[日本語](languages/日本語.md)** | **[Tiếng Việt](languages/tiếng_việt.md)** | **[Indonesia](languages/indonesia.md)** | 16 | 17 | **ACsv** is an easy, multi-platform and powerful **"csv parsing library"**. 18 | The features: 19 | * **Multi-platform** - provides **Haxe**, **JS**, **TS**, **PHP**, **Java**, **Python**, **C#**, and **Golang** versions 20 | * **Standard** - supports standard CSV format (RFC 4180) 21 | * **Easy to use** - provides example, demos and documentations 22 | * **Fast speed** - optimized code for high performance. It can work easily in older devices. 23 | * **Powerful** - supports **enhanced** CSV format; 24 |       allows field type to be declared after the field name (like [![](https://img.shields.io/badge/name-:string-blue)]()); 25 |       supported field types: **bool, int, number, string, json, strings**; 26 |       See details in "release/csvs/enhanced_format_text.csv" 27 |       - compatibles with unicdoe BOM 28 | 29 | Example 30 | ---------------- 31 | ```javascript 32 | // enhanced_csv_content 33 | //---------------------------------------------------------------- 34 | //| id:int | name:string | age:int | weight:number | tags:json | 35 | //|--------------------------------------------------------------| 36 | //| 1 | John | 20 | 60.1 | ["cool"] | 37 | //| 2 | Mary | 20 | 60.2 | ["thin"] | 38 | //| 3 | Tom | 18 | 60.3 | ["young"] | 39 | //---------------------------------------------------------------- 40 | 41 | var table = acsv.Table.Parse(enhanced_csv_content); 42 | table.selectWhenE(1, 3).toFirstObj(); 43 | // {id: 3, name: "Tom", age: 18, weight: 60.3, tags: ["young"] } 44 | 45 | table.selectWhenE(0, 20, 2).toObjs(); 46 | // [ 47 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] }, 48 | // {id: 2, name: "Mary", age: 20, weight: 60.2, tags: ["thin"] } 49 | // ] 50 | 51 | // Method Chaining Usage 52 | table.selectWhenE(0, 20, 2).selectWhenL(0, false, 60.2).toObjs(); 53 | // [ 54 | // {id: 1, name: "John", age: 20, weight: 60.1, tags: ["cool"] } 55 | // ] 56 | ``` 57 | 58 | Demos 59 | ---------------- 60 | * [Javascript demo - via Haxe code to compile](https://amin2312.github.io/ACsv/release/js/demo.html) 61 | * [Javascript demo - via Typescript code to compile](https://amin2312.github.io/ACsv/release/ts/demo.html) 62 | 63 | Docs 64 | ---------------- 65 | [Online docs - via dox](https://amin2312.github.io/ACsv/release/docs/hx/index.html) 66 | 67 | Others 68 | ---------------- 69 | ***⭐ If you like this project, please add a star ⭐*** -------------------------------------------------------------------------------- /src/java/org/json/JSON.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.json; 18 | 19 | class JSON { 20 | /** 21 | * Returns the input if it is a JSON-permissible value; throws otherwise. 22 | */ 23 | static double checkDouble(double d) throws JSONException { 24 | if (Double.isInfinite(d) || Double.isNaN(d)) { 25 | throw new JSONException("Forbidden numeric value: " + d); 26 | } 27 | return d; 28 | } 29 | 30 | static Boolean toBoolean(Object value) { 31 | if (value instanceof Boolean) { 32 | return (Boolean) value; 33 | } else if (value instanceof String) { 34 | String stringValue = (String) value; 35 | if ("true".equalsIgnoreCase(stringValue)) { 36 | return true; 37 | } else if ("false".equalsIgnoreCase(stringValue)) { 38 | return false; 39 | } 40 | } 41 | return null; 42 | } 43 | 44 | static Double toDouble(Object value) { 45 | if (value instanceof Double) { 46 | return (Double) value; 47 | } else if (value instanceof Number) { 48 | return ((Number) value).doubleValue(); 49 | } else if (value instanceof String) { 50 | try { 51 | return Double.valueOf((String) value); 52 | } catch (NumberFormatException ignored) { 53 | } 54 | } 55 | return null; 56 | } 57 | 58 | static Integer toInteger(Object value) { 59 | if (value instanceof Integer) { 60 | return (Integer) value; 61 | } else if (value instanceof Number) { 62 | return ((Number) value).intValue(); 63 | } else if (value instanceof String) { 64 | try { 65 | return (int) Double.parseDouble((String) value); 66 | } catch (NumberFormatException ignored) { 67 | } 68 | } 69 | return null; 70 | } 71 | 72 | static Long toLong(Object value) { 73 | if (value instanceof Long) { 74 | return (Long) value; 75 | } else if (value instanceof Number) { 76 | return ((Number) value).longValue(); 77 | } else if (value instanceof String) { 78 | try { 79 | return (long) Double.parseDouble((String) value); 80 | } catch (NumberFormatException ignored) { 81 | } 82 | } 83 | return null; 84 | } 85 | 86 | static String toString(Object value) { 87 | if (value instanceof String) { 88 | return (String) value; 89 | } else if (value != null) { 90 | return String.valueOf(value); 91 | } 92 | return null; 93 | } 94 | 95 | public static JSONException typeMismatch(Object indexOrName, Object actual, 96 | String requiredType) throws JSONException { 97 | if (actual == null) { 98 | throw new JSONException("Value at " + indexOrName + " is null."); 99 | } else { 100 | throw new JSONException("Value " + actual + " at " + indexOrName 101 | + " of type " + actual.getClass().getName() 102 | + " cannot be converted to " + requiredType); 103 | } 104 | } 105 | 106 | public static JSONException typeMismatch(Object actual, String requiredType) 107 | throws JSONException { 108 | if (actual == null) { 109 | throw new JSONException("Value is null."); 110 | } else { 111 | throw new JSONException("Value " + actual 112 | + " of type " + actual.getClass().getName() 113 | + " cannot be converted to " + requiredType); 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/php/demo.php: -------------------------------------------------------------------------------- 1 | selectAll()->toRows()); 31 | P('select ALL to objs', $_tab1->selectAll()->toObjs()); 32 | P('select first row', $_tab1->selectFirstRow()->toFirstRow()); 33 | P('select first obj', $_tab1->selectFirstRow()->toFirstObj()); 34 | P('select last row', $_tab1->selectLastRow()->toFirstRow()); 35 | P('select last obj', $_tab1->selectLastRow()->toFirstObj()); 36 | 37 | P('selectWhenE (id) = "2"', $_tab1->selectWhenE(1, "2")->toFirstObj()); 38 | P('selectWhenE (id) = "3" and (id2) = "21"', $_tab1->selectWhenE2(1, "3", "21")->toFirstObj()); 39 | P('selectWhenE (id) = "4" and (id2) = "21" and (id3) = "200"', $_tab1->selectWhenE3(1, "4", "21", "200")->toFirstObj()); 40 | P('selectWhenE ALL (id2) = "20"', $_tab1->selectWhenE(0, "20", 1)->toObjs()); 41 | P('merge tables', $_tab1->merge($_tab1)->selectAll()->toRows()); 42 | } 43 | function test_enhanced_csv_format() 44 | { 45 | global $_tab2; 46 | P('[E] select ALL to rows', $_tab2->selectAll()->toRows()); 47 | P('[E] select ALL to objs', $_tab2->selectAll()->toObjs()); 48 | P('[E] select first row', $_tab2->selectFirstRow()->toFirstRow()); 49 | P('[E] select first obj', $_tab2->selectFirstRow()->toFirstObj()); 50 | P('[E] select last row', $_tab2->selectLastRow()->toFirstRow()); 51 | P('[E] select last obj', $_tab2->selectLastRow()->toFirstObj()); 52 | 53 | P('[E] selectWhenE (id) = 2', $_tab2->selectWhenE(1, 2)->toFirstObj()); 54 | P('[E] selectWhenE (id) = -1', $_tab2->selectWhenE(1, -1)->toFirstObj()); 55 | P('[E] selectWhenE2 (id) = 3 and (id2) = 22', $_tab2->selectWhenE2(1, 3, 22)->toFirstObj()); 56 | P('[E] selectWhenE2 (id) = 3 and (id2) = -1', $_tab2->selectWhenE2(1, 3, -1)->toFirstObj()); 57 | P('[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = 200', $_tab2->selectWhenE3(1, 4, 22, 200)->toFirstObj()); 58 | P('[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = -1', $_tab2->selectWhenE3(1, 4, 22, -1)->toFirstObj()); 59 | P('[E] selectWhenE ALL (id2) = 21', $_tab2->selectWhenE(0, 21, 1)->toObjs()); 60 | P('[E] selectWhenE ALL (id2) = -1', $_tab2->selectWhenE(0, -1, 1)->toObjs()); 61 | 62 | P('[E] selectWhenG ALL (id2) > 25', $_tab2->selectWhenG(0, false, 25, 1)->toObjs()); 63 | P('[E] selectWhenG ALL (id2) >= 25', $_tab2->selectWhenG(0, true, 25, 1)->toObjs()); 64 | P('[E] selectWhenG ALL (id2) > 30', $_tab2->selectWhenG(0, false, 30, 1)->toObjs()); 65 | P('[E] selectWhenL ALL (id2) < 22', $_tab2->selectWhenL(0, false, 22, 1)->toObjs()); 66 | P('[E] selectWhenL ALL (id2) <= 22', $_tab2->selectWhenL(0, true, 22, 1)->toObjs()); 67 | P('[E] selectWhenL ALL (id2) < 20', $_tab2->selectWhenL(0, true, 20, 1)->toObjs()); 68 | P('[E] selectWhenGreaterAndLess ALL (id2) > 21 and (id2) < 24', $_tab2->selectWhenGreaterAndLess(0, false, false, 21, 24, 1)->toObjs()); 69 | P('[E] selectWhenGreaterAndLess ALL (id2) >= 21 and (id2) <= 24', $_tab2->selectWhenGreaterAndLess(0, true, true, 21, 24, 1)->toObjs()); 70 | P('[E] selectWhenLessOrGreater ALL (id2) < 22 or (id2) > 25', $_tab2->selectWhenLessOrGreater(0, false, false, 22, 25, 1)->toObjs()); 71 | P('[E] selectWhenLessOrGreater ALL (id2) <= 22 or (id2) >= 25', $_tab2->selectWhenLessOrGreater(0, true, true, 22, 25, 1)->toObjs()); 72 | P('[E] selectWhenIn (id) in 3,4,5', $_tab2->selectWhenIn(1, [3, 4, 5])->toObjs()); 73 | P('[E] selectAt rows at 0,1,10', $_tab2->selectAt([0, 1, 10])->toObjs()); 74 | 75 | P('[E] multi selects (id3) = 100 and (id2) < 22', $_tab2->selectWhenE(0, 100, 2)->selectWhenL(0, false, 22, 1)->toObjs()); 76 | P('[E] sort by (id3) = 300 desc (id)', $_tab2->selectWhenE(0, 300, 2)->sortBy(0, 1)->toObjs()); 77 | 78 | $_tab2->createIndexAt(0); 79 | P("[E] (indexed) 1st row name", $_tab2->selectWhenE(1, 'Dwi', $_tab2->getColIndexBy('name'))->toObjs()[0]['name']); 80 | P("[E] (indexed) id=6 education.CC", $_tab2->id(6)['education']->CC); 81 | P("[E] (indexed) id=6 tags #2", $_tab2->id(6)['tags'][1]); 82 | P("[E] (indexed) 99th row", $_tab2->selectWhenE(1, 99)->toObjs()); 83 | } 84 | main(); 85 | -------------------------------------------------------------------------------- /release/docs/hx/haxe-nav.css: -------------------------------------------------------------------------------- 1 | nav.nav { 2 | font-family: "Open Sans", sans-serif; 3 | font-size: 16px; 4 | margin: 0; 5 | } 6 | 7 | nav .fa { 8 | color: #777; 9 | margin-right: 5px; 10 | } 11 | 12 | body nav * { 13 | line-height: 20px; 14 | } 15 | 16 | nav .navbar-inner { 17 | background: #13110f; 18 | border: 0; 19 | border-radius: 0; 20 | } 21 | 22 | nav .navbar .nav { 23 | margin: 0; 24 | 25 | } 26 | 27 | .sidebar-nav { 28 | max-height: 70vh; 29 | overflow-y: auto; 30 | } 31 | 32 | nav .dropdown-menu { 33 | background: #2c2722; 34 | font-size: 14px; 35 | border-radius: 0px 0px 2px 2px; 36 | padding: 10px 0px; 37 | border: 1px solid #2c2722; 38 | margin-top: -1px; 39 | } 40 | 41 | nav .navbar .nav>li>a { 42 | padding: 14px 12px 15px 12px; 43 | color: #ccc; 44 | } 45 | 46 | nav .dropdown-menu li a { 47 | color: #b8b5b5; 48 | padding: 3px 15px; 49 | } 50 | 51 | nav .divider { 52 | background-color: transparent; 53 | border-right: 1px solid #39332d; 54 | margin: 5px 20px 5px 10px; 55 | height: 39px; 56 | } 57 | 58 | nav .dropdown-menu .divider { 59 | background-color: transparent; 60 | border: 0; 61 | border-bottom: 1px solid #39332d; 62 | margin: 5px 0; 63 | } 64 | 65 | nav .navbar-inverse .nav .active>a, 66 | nav .navbar-inverse .nav .active>a:hover, 67 | nav .navbar-inverse .nav .active>a:focus, 68 | nav .navbar-inverse .nav li.dropdown.open>.dropdown-toggle, 69 | nav .navbar-inverse .nav li.dropdown.active>.dropdown-toggle, 70 | nav .navbar-inverse .nav li.dropdown.open.active>.dropdown-toggle { 71 | color: #fff; 72 | background-color: transparent; 73 | background-image: none; 74 | } 75 | 76 | nav .navbar-inverse .nav .active>a:hover { 77 | background: #39332d; 78 | } 79 | 80 | nav .dropdown-menu>.active>a, 81 | nav .dropdown-menu>.active>a:hover, 82 | nav .dropdown-menu>.active>a:focus { 83 | font-weight: bold; 84 | color: #fff; 85 | background-image: none; 86 | background: #39332d; 87 | } 88 | 89 | nav .dropdown-menu>li>a:hover, 90 | .dropdown-menu>li>a:focus, 91 | nav .dropdown-submenu:hover>a, 92 | nav .dropdown-submenu:focus>a { 93 | background: #39332d; 94 | } 95 | 96 | nav .navbar .nav>li>.dropdown-menu:after { 97 | border-bottom-color: #2c2722; 98 | } 99 | 100 | .nav>li>a.selected, 101 | .nav>li>a:hover { 102 | background-color: #00000010; 103 | } 104 | 105 | /** MEDIA Q **/ 106 | 107 | @media (max-width: 979px) { 108 | 109 | nav .navbar-fixed-top .navbar-inner, 110 | nav .navbar-fixed-bottom .navbar-inner { 111 | padding: 0px; 112 | } 113 | 114 | nav .navbar-fixed-top { 115 | margin-bottom: 0; 116 | } 117 | } 118 | 119 | /** SUB BRAND LOGOS **/ 120 | 121 | .navbar .brand.haxe-logo { 122 | padding-right: 0; 123 | margin: 3px 0 0 0px; 124 | } 125 | 126 | .navbar .brand.haxe-logo:hover { 127 | opacity: .9; 128 | } 129 | 130 | .navbar .brand.haxe-logo:after { 131 | content: " "; 132 | position: absolute; 133 | /* create arrow */ 134 | width: 0; 135 | height: 0; 136 | border-top: 22px solid transparent; 137 | border-bottom: 22px solid transparent; 138 | border-left: 7px solid #13110f; 139 | /* same color as nav bar */ 140 | top: 0; 141 | } 142 | 143 | .navbar .brand.sub { 144 | background: #39332d; 145 | /* Old browsers */ 146 | background: -moz-linear-gradient(top, #39332d 50%, #2c2722 51%); 147 | /* FF3.6+ */ 148 | background: -webkit-gradient(linear, left top, left bottom, color-stop(50%, #39332d), color-stop(51%, #2c2722)); 149 | /* Chrome,Safari4+ */ 150 | background: -webkit-linear-gradient(top, #39332d 50%, #2c2722 51%); 151 | /* Chrome10+,Safari5.1+ */ 152 | background: -o-linear-gradient(top, #39332d 50%, #2c2722 51%); 153 | /* Opera 11.10+ */ 154 | background: -ms-linear-gradient(top, #39332d 50%, #2c2722 51%); 155 | /* IE10+ */ 156 | background: linear-gradient(to bottom, #39332d 50%, #2c2722 51%); 157 | /* W3C */ 158 | padding: 14px 20px 13px 20px; 159 | margin: 0 10px 0 0; 160 | font: bold 18px "arial black", "open sans"; 161 | line-height: 22px; 162 | color: rgb(255, 255, 255); 163 | } 164 | 165 | .navbar .brand.sub:hover { 166 | color: rgb(230, 230, 230); 167 | background: #2c2722; 168 | /* Old browsers */ 169 | } 170 | 171 | .navbar .brand.sub:before { 172 | content: ".."; 173 | /* two dots */ 174 | position: absolute; 175 | margin-left: -33px; 176 | margin-top: -28px; 177 | line-height: 0px; 178 | font: bold 40px "Open Sans", sans-serif; 179 | letter-spacing: 0px; 180 | color: #fff200; 181 | } 182 | 183 | /** SUB BRAND COLORS **/ 184 | 185 | .navbar .brand.sub.try:before { 186 | color: #f89c0e; 187 | } 188 | 189 | .navbar .brand.sub.api:before { 190 | color: #eedc16; 191 | } 192 | 193 | .navbar .brand.sub.lib:before { 194 | color: #f1471d; 195 | } 196 | 197 | .navbar .brand.sub.ide:before { 198 | color: #f89c0e; 199 | } -------------------------------------------------------------------------------- /src/golang/Demo.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "acsv" 5 | . "fmt" 6 | "io/ioutil" 7 | ) 8 | 9 | /** 10 | * Tables 11 | */ 12 | var _tab1 *acsv.Table 13 | var _tab2 *acsv.Table 14 | 15 | /** 16 | * Main Entry. 17 | * @return 18 | */ 19 | func main() { 20 | var standard_format_text = readToString("../../release/csvs/standard_format_text.csv") 21 | _tab1 = acsv.Parse(standard_format_text) 22 | test_standard_csv_format() 23 | var enhanced_format_text = readToString("../../release/csvs/enhanced_format_text.csv") 24 | _tab2 = acsv.Parse(enhanced_format_text) 25 | test_enhanced_csv_format() 26 | } 27 | 28 | func P(cmd string, o interface{}) { 29 | Println(cmd) 30 | nilVal, ok := o.(map[string]interface{}) 31 | if o == nil { 32 | Println("nil") 33 | } else if ok && nilVal == nil { 34 | Println("nil") 35 | } else { 36 | Printf("%v", o) 37 | } 38 | Println("\n") 39 | } 40 | 41 | func test_standard_csv_format() { 42 | P("select ALL to rows", _tab1.SelectAll().ToRows()) 43 | P("select ALL to objs", _tab1.SelectAll().ToObjs()) 44 | P("select first row", _tab1.SelectFirstRow().ToFirstRow()) 45 | P("select first obj", _tab1.SelectFirstRow().ToFirstObj()) 46 | P("select last row", _tab1.SelectLastRow().ToFirstRow()) 47 | P("select last obj", _tab1.SelectLastRow().ToFirstObj()) 48 | 49 | P("selectWhenE (id) = \"2\"", _tab1.SelectWhenE(1, "2", 0, nil).ToFirstObj()) 50 | P("selectWhenE (id) = \"3\" and (id2) = \"21\"", _tab1.SelectWhenE2(1, "3", "21", 1, 0).ToFirstObj()) 51 | P("selectWhenE (id) = \"4\" and (id2) = \"21\" and (id3) = \"200\"", _tab1.SelectWhenE3(1, "4", "21", "200", 2, 1, 0).ToFirstObj()) 52 | P("selectWhenE ALL (id2) = \"20\"", _tab1.SelectWhenE(0, "20", 1, nil).ToObjs()) 53 | P("merge tables", _tab1.Merge(_tab1).SelectAll().ToRows()) 54 | } 55 | 56 | func test_enhanced_csv_format() { 57 | P("[E] select ALL to rows", _tab2.SelectAll().ToRows()) 58 | P("[E] select ALL to objs", _tab2.SelectAll().ToObjs()) 59 | P("[E] select first row", _tab2.SelectFirstRow().ToFirstRow()) 60 | P("[E] select first obj", _tab2.SelectFirstRow().ToFirstObj()) 61 | 62 | P("[E] select last row", _tab2.SelectLastRow().ToFirstRow()) 63 | P("[E] select last obj", _tab2.SelectLastRow().ToFirstObj()) 64 | 65 | P("[E] selectWhenE (id) = 2", _tab2.SelectWhenE(1, 2, 0, nil).ToFirstObj()) 66 | P("[E] selectWhenE (id) = -1", _tab2.SelectWhenE(1, -1, 0, nil).ToFirstObj()) 67 | P("[E] selectWhenE2 (id) = 3 and (id2) = 22", _tab2.SelectWhenE2(1, 3, 22, 1, 0).ToFirstObj()) 68 | P("[E] selectWhenE2 (id) = 3 and (id2) = -1", _tab2.SelectWhenE2(1, 3, -1, 1, 0).ToFirstObj()) 69 | P("[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = 200", _tab2.SelectWhenE3(1, 4, 22, 200, 2, 1, 0).ToFirstObj()) 70 | P("[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = -1", _tab2.SelectWhenE3(1, 4, 22, -1, 2, 1, 0).ToFirstObj()) 71 | P("[E] selectWhenE ALL (id2) = 21", _tab2.SelectWhenE(0, 21, 1, nil).ToObjs()) 72 | P("[E] selectWhenE ALL (id2) = -1", _tab2.SelectWhenE(0, -1, 1, nil).ToObjs()) 73 | 74 | P("[E] selectWhenG ALL (id2) > 25", _tab2.SelectWhenG(0, false, 25, 1).ToObjs()) 75 | P("[E] selectWhenG ALL (id2) >= 25", _tab2.SelectWhenG(0, true, 25, 1).ToObjs()) 76 | P("[E] selectWhenG ALL (id2) > 30", _tab2.SelectWhenG(0, false, 30, 1).ToObjs()) 77 | P("[E] selectWhenL ALL (id2) < 22", _tab2.SelectWhenL(0, false, 22, 1).ToObjs()) 78 | P("[E] selectWhenL ALL (id2) <= 22", _tab2.SelectWhenL(0, true, 22, 1).ToObjs()) 79 | P("[E] selectWhenL ALL (id2) < 20", _tab2.SelectWhenL(0, true, 20, 1).ToObjs()) 80 | P("[E] selectWhenGreaterAndLess ALL (id2) > 21 and (id2) < 24", _tab2.SelectWhenGreaterAndLess(0, false, false, 21, 24, 1).ToObjs()) 81 | P("[E] selectWhenGreaterAndLess ALL (id2) >= 21 and (id2) <= 24", _tab2.SelectWhenGreaterAndLess(0, true, true, 21, 24, 1).ToObjs()) 82 | P("[E] selectWhenLessOrGreater ALL (id2) < 22 or (id2) > 25", _tab2.SelectWhenLessOrGreater(0, false, false, 22, 25, 1).ToObjs()) 83 | P("[E] selectWhenLessOrGreater ALL (id2) <= 22 or (id2) >= 25", _tab2.SelectWhenLessOrGreater(0, true, true, 22, 25, 1).ToObjs()) 84 | P("[E] selectWhenIn (id) in 3,4,5", _tab2.SelectWhenIn(1, []interface{}{3, 4, 5}, 0).ToObjs()) 85 | P("[E] selectAt rows at 0,1,10", _tab2.SelectAt([]int{0, 1, 10}).ToObjs()) 86 | 87 | P("[E] multi selects (id3) = 100 and (id2) < 22", _tab2.SelectWhenE(0, 100, 2, nil).SelectWhenL(0, false, 22, 1).ToObjs()) 88 | P("[E] sort by (id3) = 300 desc (id)", _tab2.SelectWhenE(0, 300, 2, nil).SortBy(0, 1).ToObjs()) 89 | 90 | _tab2.CreateIndexAt(0) 91 | P("[E] (indexed) 1st row name", _tab2.SelectWhenE(1, "Dwi", _tab2.GetColIndexBy("name"), nil).ToObjs()[0]["name"]) 92 | P("[E] (indexed) id=6 education.CC", _tab2.Id(6, 0).(map[string]interface{})["education"].(map[string]interface{})["CC"]) 93 | P("[E] (indexed) id=6 tags #2", _tab2.Id(6, 0).(map[string]interface{})["tags"].([]interface{})[1]) 94 | P("[E] (indexed) 99th row", _tab2.SelectWhenE(1, 99, 0, nil).ToObjs()) 95 | } 96 | 97 | func readToString(fileName string) string { 98 | bytes, err := ioutil.ReadFile(fileName) 99 | if err != nil { 100 | Printf("%v", err) 101 | } 102 | return string(bytes) 103 | } 104 | -------------------------------------------------------------------------------- /src/python/demo.py: -------------------------------------------------------------------------------- 1 | # -*- coding: UTF-8 -*- 2 | 3 | import acsv; 4 | import json; 5 | import os; 6 | 7 | class Demo: 8 | 9 | def __init__(self): 10 | srcDir = os.path.dirname(__file__) 11 | f = open(srcDir + "/../../release/csvs/standard_format_text.csv", "r", encoding='utf8') 12 | self._tab1 = acsv.Table.Parse(f.read()) 13 | self.test_standard_csv_format() 14 | f = open(srcDir + "/../../release/csvs/enhanced_format_text.csv", "r", encoding='utf8') 15 | self._tab2 = acsv.Table.Parse(f.read()) 16 | self.test_enhanced_csv_format() 17 | 18 | def P(self, cmd, o): 19 | print(cmd) 20 | if (o is None): 21 | print(str(None)) 22 | else: 23 | print(o) 24 | #print(json.dumps(o, ensure_ascii=False)) 25 | print('\n') 26 | 27 | def test_standard_csv_format(self): 28 | self.P("select ALL to rows",self._tab1.selectAll().toRows()) 29 | self.P("select ALL to objs",self._tab1.selectAll().toObjs()) 30 | self.P("select first row",self._tab1.selectFirstRow().toFirstRow()) 31 | self.P("select first obj",self._tab1.selectFirstRow().toFirstObj()) 32 | self.P("select last row",self._tab1.selectLastRow().toFirstRow()) 33 | self.P("select last obj",self._tab1.selectLastRow().toFirstObj()) 34 | self.P("selectWhenE (id) = \"2\"",self._tab1.selectWhenE(1,"2").toFirstObj()) 35 | self.P("selectWhenE (id) = \"3\" and (id2) = \"21\"",self._tab1.selectWhenE2(1,"3","21").toFirstObj()) 36 | self.P("selectWhenE (id) = \"4\" and (id2) = \"21\" and (id3) = \"200\"",self._tab1.selectWhenE3(1,"4","21","200").toFirstObj()) 37 | self.P("selectWhenE ALL (id2) = \"20\"",self._tab1.selectWhenE(0,"20",1).toObjs()) 38 | self.P("merge tables",self._tab1.merge(self._tab1).selectAll().toRows()) 39 | 40 | def test_enhanced_csv_format(self): 41 | self.P("[E] select ALL to rows",self._tab2.selectAll().toRows()) 42 | self.P("[E] select ALL to objs",self._tab2.selectAll().toObjs()) 43 | self.P("[E] select first row",self._tab2.selectFirstRow().toFirstRow()) 44 | self.P("[E] select first obj",self._tab2.selectFirstRow().toFirstObj()) 45 | self.P("[E] select last row",self._tab2.selectLastRow().toFirstRow()) 46 | self.P("[E] select last obj",self._tab2.selectLastRow().toFirstObj()) 47 | self.P("[E] selectWhenE (id) = 2",self._tab2.selectWhenE(1,2).toFirstObj()) 48 | self.P("[E] selectWhenE (id) = -1",self._tab2.selectWhenE(1,-1).toFirstObj()) 49 | self.P("[E] selectWhenE2 (id) = 3 and (id2) = 22",self._tab2.selectWhenE2(1,3,22).toFirstObj()) 50 | self.P("[E] selectWhenE2 (id) = 3 and (id2) = -1",self._tab2.selectWhenE2(1,3,-1).toFirstObj()) 51 | self.P("[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = 200",self._tab2.selectWhenE3(1,4,22,200).toFirstObj()) 52 | self.P("[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = -1",self._tab2.selectWhenE3(1,4,22,-1).toFirstObj()) 53 | self.P("[E] selectWhenE ALL (id2) = 21",self._tab2.selectWhenE(0,21,1).toObjs()) 54 | self.P("[E] selectWhenE ALL (id2) = -1",self._tab2.selectWhenE(0,-1,1).toObjs()) 55 | self.P("[E] selectWhenG ALL (id2) > 25",self._tab2.selectWhenG(0,False,25,1).toObjs()) 56 | self.P("[E] selectWhenG ALL (id2) >= 25",self._tab2.selectWhenG(0,True,25,1).toObjs()) 57 | self.P("[E] selectWhenG ALL (id2) > 30",self._tab2.selectWhenG(0,False,30,1).toObjs()) 58 | self.P("[E] selectWhenL ALL (id2) < 22",self._tab2.selectWhenL(0,False,22,1).toObjs()) 59 | self.P("[E] selectWhenL ALL (id2) <= 22",self._tab2.selectWhenL(0,True,22,1).toObjs()) 60 | self.P("[E] selectWhenL ALL (id2) < 20",self._tab2.selectWhenL(0,True,20,1).toObjs()) 61 | self.P("[E] selectWhenGreaterAndLess ALL (id2) > 21 and (id2) < 24",self._tab2.selectWhenGreaterAndLess(0,False,False,21,24,1).toObjs()) 62 | self.P("[E] selectWhenGreaterAndLess ALL (id2) >= 21 and (id2) <= 24",self._tab2.selectWhenGreaterAndLess(0,True,True,21,24,1).toObjs()) 63 | self.P("[E] selectWhenLessOrGreater ALL (id2) < 22 or (id2) > 25",self._tab2.selectWhenLessOrGreater(0,False,False,22,25,1).toObjs()) 64 | self.P("[E] selectWhenLessOrGreater ALL (id2) <= 22 or (id2) >= 25",self._tab2.selectWhenLessOrGreater(0,True,True,22,25,1).toObjs()) 65 | self.P("[E] selectWhenIn (id) in 3,4,5",self._tab2.selectWhenIn(1,[3, 4, 5]).toObjs()) 66 | self.P("[E] selectAt rows at 0,1,10",self._tab2.selectAt([0, 1, 10]).toObjs()) 67 | self.P("[E] multi selects (id3) = 100 and (id2) < 22",self._tab2.selectWhenE(0,100,2).selectWhenL(0,False,22,1).toObjs()) 68 | self.P("[E] sort by (id3) = 300 desc (id)",self._tab2.selectWhenE(0,300,2).sortBy(0,1).toObjs()) 69 | self._tab2.createIndexAt(0) 70 | self.P("[E] (indexed) 1st row name",self._tab2.selectWhenE(1,"Dwi",self._tab2.getColIndexBy("name")).toObjs()[0]["name"]) 71 | self.P("[E] (indexed) id=6 education.CC",self._tab2.id(6)["education"]["CC"]) 72 | self.P("[E] (indexed) id=6 tags #2",self._tab2.id(6)["tags"][1]) 73 | self.P("[E] (indexed) 99th row",self._tab2.selectWhenE(1, 99).toObjs()) 74 | 75 | Demo() -------------------------------------------------------------------------------- /release/docs/hx/bootstrap/css/bootstrap-select.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap-select v1.6.3 (http://silviomoreto.github.io/bootstrap-select/) 3 | * 4 | * Copyright 2013-2014 bootstrap-select 5 | * Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE) 6 | */.bootstrap-select{width:220px \0}.bootstrap-select>.btn{width:100%;padding-right:25px}.error .bootstrap-select .btn{border:1px solid #b94a48}.control-group.error .bootstrap-select .dropdown-toggle{border-color:#b94a48}.bootstrap-select.fit-width{width:auto!important}.bootstrap-select:not([class*=col-]):not([class*=form-control]):not(.input-group-btn){width:220px}.bootstrap-select .btn:focus{outline:thin dotted #333!important;outline:5px auto -webkit-focus-ring-color!important;outline-offset:-2px}.bootstrap-select.form-control{margin-bottom:0;padding:0;border:none}.bootstrap-select.form-control:not([class*=col-]){width:100%}.bootstrap-select.btn-group:not(.input-group-btn),.bootstrap-select.btn-group[class*=col-]{float:none;display:inline-block;margin-left:0}.bootstrap-select.btn-group.dropdown-menu-right,.bootstrap-select.btn-group[class*=col-].dropdown-menu-right,.row-fluid .bootstrap-select.btn-group[class*=col-].dropdown-menu-right{float:right}.form-search .bootstrap-select.btn-group,.form-inline .bootstrap-select.btn-group,.form-horizontal .bootstrap-select.btn-group,.form-group .bootstrap-select.btn-group{margin-bottom:0}.form-group-lg .bootstrap-select.btn-group.form-control,.form-group-sm .bootstrap-select.btn-group.form-control{padding:0}.form-inline .bootstrap-select.btn-group .form-control{width:100%}.input-append .bootstrap-select.btn-group{margin-left:-1px}.input-prepend .bootstrap-select.btn-group{margin-right:-1px}.bootstrap-select.btn-group>.disabled{cursor:not-allowed}.bootstrap-select.btn-group>.disabled:focus{outline:0!important}.bootstrap-select.btn-group .btn .filter-option{display:inline-block;overflow:hidden;width:100%;text-align:left}.bootstrap-select.btn-group .btn .caret{position:absolute;top:50%;right:12px;margin-top:-2px;vertical-align:middle}.bootstrap-select.btn-group[class*=col-] .btn{width:100%}.bootstrap-select.btn-group .dropdown-menu{min-width:100%;z-index:1035;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bootstrap-select.btn-group .dropdown-menu.inner{position:static;border:0;padding:0;margin:0;border-radius:0;-webkit-box-shadow:none;box-shadow:none}.bootstrap-select.btn-group .dropdown-menu li{position:relative}.bootstrap-select.btn-group .dropdown-menu li:not(.disabled) a:hover small,.bootstrap-select.btn-group .dropdown-menu li:not(.disabled) a:focus small,.bootstrap-select.btn-group .dropdown-menu li.active:not(.disabled) a small{color:#64b1d8;color:rgba(100,177,216,.4)}.bootstrap-select.btn-group .dropdown-menu li.disabled a{cursor:not-allowed}.bootstrap-select.btn-group .dropdown-menu li a{cursor:pointer}.bootstrap-select.btn-group .dropdown-menu li a.opt{position:relative;padding-left:2.25em}.bootstrap-select.btn-group .dropdown-menu li a span.check-mark{display:none}.bootstrap-select.btn-group .dropdown-menu li a span.text{display:inline-block}.bootstrap-select.btn-group .dropdown-menu li small{padding-left:.5em}.bootstrap-select.btn-group .dropdown-menu .notify{position:absolute;bottom:5px;width:96%;margin:0 2%;min-height:26px;padding:3px 5px;background:#f5f5f5;border:1px solid #e3e3e3;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.05);box-shadow:inset 0 1px 1px rgba(0,0,0,.05);pointer-events:none;opacity:.9;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bootstrap-select.btn-group .no-results{padding:3px;background:#f5f5f5;margin:0 5px}.bootstrap-select.btn-group.fit-width .btn .filter-option{position:static}.bootstrap-select.btn-group.fit-width .btn .caret{position:static;top:auto;margin-top:-1px}.bootstrap-select.btn-group.show-tick .dropdown-menu li.selected a span.check-mark{position:absolute;display:inline-block;right:15px;margin-top:5px}.bootstrap-select.btn-group.show-tick .dropdown-menu li a span.text{margin-right:34px}.bootstrap-select.show-menu-arrow.open>.btn{z-index:1035+1}.bootstrap-select.show-menu-arrow .dropdown-toggle:before{content:'';border-left:7px solid transparent;border-right:7px solid transparent;border-bottom-width:7px;border-bottom-style:solid;border-bottom-color:#ccc;border-bottom-color:rgba(204,204,204,.2);position:absolute;bottom:-4px;left:9px;display:none}.bootstrap-select.show-menu-arrow .dropdown-toggle:after{content:'';border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #fff;position:absolute;bottom:-4px;left:10px;display:none}.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle:before{bottom:auto;top:-3px;border-bottom:0;border-top-width:7px;border-top-style:solid;border-top-color:#ccc;border-top-color:rgba(204,204,204,.2)}.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle:after{bottom:auto;top:-3px;border-top:6px solid #fff;border-bottom:0}.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle:before{right:12px;left:auto}.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle:after{right:13px;left:auto}.bootstrap-select.show-menu-arrow.open>.dropdown-toggle:before,.bootstrap-select.show-menu-arrow.open>.dropdown-toggle:after{display:block}.bs-searchbox,.bs-actionsbox{padding:4px 8px}.bs-actionsbox{float:left;width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bs-actionsbox .btn-group button{width:50%}.bs-searchbox+.bs-actionsbox{padding:0 8px 4px}.bs-searchbox input.form-control{margin-bottom:0;width:100%}.mobile-device{position:absolute;top:0;left:0;display:block!important;width:100%;height:100%!important;opacity:0} -------------------------------------------------------------------------------- /release/ts/demo.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /// 3 | /** 4 | * Tables 5 | */ 6 | var _tab1; 7 | var _tab2; 8 | /** 9 | * Entry. 10 | */ 11 | function main() { 12 | var xhr = new XMLHttpRequest(); 13 | xhr.open("GET", "../../release/csvs/standard_format_text.csv", false); 14 | xhr.send(); 15 | var standard_format_text = xhr.responseText; 16 | _tab1 = acsv.Table.Parse(standard_format_text); 17 | var xhr = new XMLHttpRequest(); 18 | xhr.open("GET", "../../release/csvs/enhanced_format_text.csv", false); 19 | xhr.send(); 20 | var enhanced_format_text = xhr.responseText; 21 | _tab2 = acsv.Table.Parse(enhanced_format_text); 22 | showTable("standard csv format", _tab1); 23 | test_standard_csv_format(); 24 | showTable("[E] enhanced csv format", _tab2); 25 | test_enhanced_csv_format(); 26 | } 27 | function showTable(fileName, csvTable) { 28 | var t = document.getElementById('output'); 29 | var tab = document.createElement('table'); 30 | { 31 | var thead = document.createElement('thead'); 32 | var tr = document.createElement('tr'); 33 | thead.appendChild(tr); 34 | for (var i = 0; i < csvTable.head.length; i++) { 35 | var td = document.createElement('td'); 36 | var rowI = csvTable.head[i]; 37 | td.innerText = rowI.fullName; 38 | tr.appendChild(td); 39 | } 40 | tab.appendChild(thead); 41 | } 42 | { 43 | var tbody = document.createElement('tbody'); 44 | for (var i = 0; i < csvTable.body.length; i++) { 45 | var tr = document.createElement('tr'); 46 | var rows = csvTable.body[i]; 47 | for (var j = 0; j < rows.length; j++) { 48 | var td = document.createElement('td'); 49 | var rowJ = rows[j]; 50 | td.innerText = rowJ; 51 | tr.appendChild(td); 52 | } 53 | tbody.appendChild(tr); 54 | } 55 | tab.appendChild(tbody); 56 | } 57 | { 58 | var tfoot = document.createElement('tfoot'); 59 | var tr = document.createElement('tr'); 60 | var td = document.createElement('td'); 61 | td.colSpan = csvTable.head.length; 62 | td.innerText = fileName; 63 | tr.appendChild(td); 64 | tfoot.appendChild(tr); 65 | tab.appendChild(tfoot); 66 | } 67 | t.appendChild(tab); 68 | } 69 | function P(cmd, o) { 70 | var t = document.getElementById('output'); 71 | var div = document.createElement('div'); 72 | var span = document.createElement('span'); 73 | span.innerHTML = cmd.replace('[E]', '[E]'); 74 | div.appendChild(span); 75 | div.title = JSON.stringify(o, null, '\t'); 76 | div.innerHTML += JSON.stringify(o); 77 | t.appendChild(div); 78 | console.log(cmd); 79 | if (o == null) // fix some language's bug 80 | { 81 | console.log(null); 82 | } 83 | else { 84 | console.log(o); 85 | } 86 | } 87 | function test_standard_csv_format() { 88 | P('select ALL to rows', _tab1.selectAll().toRows()); 89 | P('select ALL to objs', _tab1.selectAll().toObjs()); 90 | P('select first row', _tab1.selectFirstRow().toFirstRow()); 91 | P('select first obj', _tab1.selectFirstRow().toFirstObj()); 92 | P('select last row', _tab1.selectLastRow().toFirstRow()); 93 | P('select last obj', _tab1.selectLastRow().toFirstObj()); 94 | P('selectWhenE (id) = "2"', _tab1.selectWhenE(1, "2").toFirstObj()); 95 | P('selectWhenE (id) = "3" and (id2) = "21"', _tab1.selectWhenE2(1, "3", "21").toFirstObj()); 96 | P('selectWhenE (id) = "4" and (id2) = "21" and (id3) = "200"', _tab1.selectWhenE3(1, "4", "21", "200").toFirstObj()); 97 | P('selectWhenE ALL (id2) = "20"', _tab1.selectWhenE(0, "20", 1).toObjs()); 98 | P('merge tables', _tab1.merge(_tab1).selectAll().toRows()); 99 | } 100 | function test_enhanced_csv_format() { 101 | P('[E] select ALL to rows', _tab2.selectAll().toRows()); 102 | P('[E] select ALL to objs', _tab2.selectAll().toObjs()); 103 | P('[E] select first row', _tab2.selectFirstRow().toFirstRow()); 104 | P('[E] select first obj', _tab2.selectFirstRow().toFirstObj()); 105 | P('[E] select last row', _tab2.selectLastRow().toFirstRow()); 106 | P('[E] select last obj', _tab2.selectLastRow().toFirstObj()); 107 | P('[E] selectWhenE (id) = 2', _tab2.selectWhenE(1, 2).toFirstObj()); 108 | P('[E] selectWhenE (id) = -1', _tab2.selectWhenE(1, -1).toFirstObj()); 109 | P('[E] selectWhenE2 (id) = 3 and (id2) = 22', _tab2.selectWhenE2(1, 3, 22).toFirstObj()); 110 | P('[E] selectWhenE2 (id) = 3 and (id2) = -1', _tab2.selectWhenE2(1, 3, -1).toFirstObj()); 111 | P('[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = 200', _tab2.selectWhenE3(1, 4, 22, 200).toFirstObj()); 112 | P('[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = -1', _tab2.selectWhenE3(1, 4, 22, -1).toFirstObj()); 113 | P('[E] selectWhenE ALL (id2) = 21', _tab2.selectWhenE(0, 21, 1).toObjs()); 114 | P('[E] selectWhenE ALL (id2) = -1', _tab2.selectWhenE(0, -1, 1).toObjs()); 115 | P('[E] selectWhenG ALL (id2) > 25', _tab2.selectWhenG(0, false, 25, 1).toObjs()); 116 | P('[E] selectWhenG ALL (id2) >= 25', _tab2.selectWhenG(0, true, 25, 1).toObjs()); 117 | P('[E] selectWhenG ALL (id2) > 30', _tab2.selectWhenG(0, false, 30, 1).toObjs()); 118 | P('[E] selectWhenL ALL (id2) < 22', _tab2.selectWhenL(0, false, 22, 1).toObjs()); 119 | P('[E] selectWhenL ALL (id2) <= 22', _tab2.selectWhenL(0, true, 22, 1).toObjs()); 120 | P('[E] selectWhenL ALL (id2) < 20', _tab2.selectWhenL(0, true, 20, 1).toObjs()); 121 | P('[E] selectWhenGreaterAndLess ALL (id2) > 21 and (id2) < 24', _tab2.selectWhenGreaterAndLess(0, false, false, 21, 24, 1).toObjs()); 122 | P('[E] selectWhenGreaterAndLess ALL (id2) >= 21 and (id2) <= 24', _tab2.selectWhenGreaterAndLess(0, true, true, 21, 24, 1).toObjs()); 123 | P('[E] selectWhenLessOrGreater ALL (id2) < 22 or (id2) > 25', _tab2.selectWhenLessOrGreater(0, false, false, 22, 25, 1).toObjs()); 124 | P('[E] selectWhenLessOrGreater ALL (id2) <= 22 or (id2) >= 25', _tab2.selectWhenLessOrGreater(0, true, true, 22, 25, 1).toObjs()); 125 | P('[E] selectWhenIn (id) in 3,4,5', _tab2.selectWhenIn(1, [3, 4, 5]).toObjs()); 126 | P('[E] selectAt rows at 0,1,10', _tab2.selectAt([0, 1, 10]).toObjs()); 127 | P('[E] multi selects (id3) = 100 and (id2) < 22', _tab2.selectWhenE(0, 100, 2).selectWhenL(0, false, 22, 1).toObjs()); 128 | P('[E] sort by (id3) = 300 desc (id)', _tab2.selectWhenE(0, 300, 2).sortBy(0, 1).toObjs()); 129 | _tab2.createIndexAt(0); 130 | P("[E] (indexed) 1st row name", _tab2.selectWhenE(1, 'Dwi', _tab2.getColIndexBy('name')).toObjs()[0].name); 131 | P("[E] (indexed) id=6 education.CC", _tab2.id(6).education.CC); 132 | P("[E] (indexed) id=6 tags #2", _tab2.id(6).tags[1]); 133 | P('[E] (indexed) 99th row', _tab2.selectWhenE(1, 99).toObjs()); 134 | } 135 | main(); 136 | -------------------------------------------------------------------------------- /src/javascript/ACsv.min.js: -------------------------------------------------------------------------------- 1 | (function(e){"use strict";e["acsv"]=e["acsv"]||{};var g=function(){};g.replace=function(e,t,r){return e.split(t).join(r)};var x=e["acsv"]["Field"]=function(){};var A=e["acsv"]["Table"]=function(){this._selector=null;this._indexSet={};this.body=[];this.head=[];this.content=null};A.Parse=function(e,t,r){if(r==null){r='"'}if(t==null){t=","}var i=A.arrayToRows(A.textToArray(e,t,r));i.content=e;return i};A.textToArray=function(e,t,r){if(r==null){r='"'}if(t==null){t=","}if(e.charCodeAt(0)==65279){e=e.substring(1)}var i=r+r;var l=[];var n=e.length;var s=e;var a=0;while(true){var h=n-a;var o=0;var u=0;var v=[];var f=null;var c=null;while(u=n){break}}return l};A.arrayToRows=function(e){var t=e.shift();var r=e;var i=[];var l=0;var n=t.length;while(lv){o=true}else if(t==1&&u0&&A.JSON_TYPES.indexOf(s)!=-1){if(a!=null){h=JSON.parse(a)}}else{h=a}t.push(h)}return t},fmtObj:function(e){var t={};var r=0;var i=this.head.length;while(r0&&A.JSON_TYPES.indexOf(a)!=-1){if(h!=null){o=JSON.parse(h)}}else{o=h}t[s]=o}return t},toFirstRow:function(){var e=null;if(this._selector!=null&&this._selector.length>0){e=this.fmtRow(this._selector[0])}this._selector=null;return e},toLastRow:function(){var e=null;if(this._selector!=null){var t=this._selector.length;if(t>0){e=this.fmtRow(this._selector[t-1])}}this._selector=null;return e},toRows:function(){if(this._selector==null){return null}var e=[];var t=0;var r=this._selector.length;while(t0){e=this.fmtObj(this._selector[0])}this._selector=null;return e},toLastObj:function(){var e=null;if(this._selector!=null){var t=this._selector.length;if(t>0){e=this.fmtObj(this._selector[t-1])}}this._selector=null;return e},toObjs:function(){if(this._selector==null){return null}var e=[];var t=0;var r=this._selector.length;while(t=0&&sr||t&&u==r){n.push(o);--e;if(e==0){break}}}this._selector=n;return this},selectWhenL:function(e,t,r,i){if(i==null){i=0}var l=this._selector;if(l==null){l=this.body}var n=[];var s=0;var a=l.length;while(si||t&&f==i;var _=fl||r&&f==l;if(c||_){a.push(v);--e;if(e==0){break}}}this._selector=a;return this}};A.JSON_TYPES=["json","strings"]})(typeof exports!="undefined"?exports:typeof window!="undefined"?window:typeof self!="undefined"?self:this); -------------------------------------------------------------------------------- /src/csharp/Demo.cs: -------------------------------------------------------------------------------- 1 | using acsv; 2 | using System; 3 | using System.IO; 4 | using System.Collections.Generic; 5 | using Newtonsoft.Json.Linq; 6 | 7 | public class Demo 8 | { 9 | /** 10 | * Tables 11 | */ 12 | private static Table _tab1; 13 | private static Table _tab2; 14 | /** 15 | * Main Entry. 16 | * @return 17 | */ 18 | static void Main() 19 | { 20 | string standard_format_text = readTostring("../../release/csvs/standard_format_text.csv"); 21 | _tab1 = Table.Parse(standard_format_text); 22 | test_standard_csv_format(); 23 | string enhanced_format_text = readTostring("../../release/csvs/enhanced_format_text.csv"); 24 | _tab2 = Table.Parse(enhanced_format_text); 25 | test_enhanced_csv_format(); 26 | } 27 | 28 | public static void P(string cmd, object o) 29 | { 30 | Console.WriteLine(cmd); 31 | if (o == null) 32 | { 33 | Console.WriteLine("null"); 34 | } 35 | else if (o is Dictionary[]) 36 | { 37 | Dictionary[] o1 = (Dictionary[])o; 38 | if (o1.Length == 0) 39 | { 40 | Console.WriteLine("[]"); 41 | } 42 | else 43 | { 44 | for (int i = 0; i < o1.GetLength(0); i++) 45 | { 46 | foreach (KeyValuePair kvp in (Dictionary)o1[i]) 47 | { 48 | Console.Write("\"{0}\":{1}, ", kvp.Key, kvp.Value); 49 | } 50 | Console.WriteLine(); 51 | } 52 | } 53 | } 54 | else if (o is Dictionary) 55 | { 56 | foreach (KeyValuePair kvp in (Dictionary)o) 57 | { 58 | Console.Write("\"{0}\":{1}, ", kvp.Key, kvp.Value); 59 | } 60 | Console.WriteLine(); 61 | } 62 | else if (o is object[][]) 63 | { 64 | object[][] o1 = (object[][])o; 65 | for (int i = 0; i < o1.GetLength(0); i++) 66 | { 67 | Console.Write(String.Join(",", o1[i]) + "\n"); 68 | } 69 | } 70 | else if (o is object[]) 71 | { 72 | object[] o1 = (object[])o; 73 | Console.Write(String.Join(",", o1) + "\n"); 74 | } 75 | else 76 | { 77 | Console.WriteLine(o); 78 | } 79 | Console.WriteLine(); 80 | } 81 | 82 | public static void test_standard_csv_format() 83 | { 84 | P("select ALL to rows", _tab1.selectAll().toRows()); 85 | P("select ALL to objs", _tab1.selectAll().toObjs()); 86 | P("select first row", _tab1.selectFirstRow().toFirstRow()); 87 | P("select first obj", _tab1.selectFirstRow().toFirstObj()); 88 | P("select last row", _tab1.selectLastRow().toFirstRow()); 89 | P("select last obj", _tab1.selectLastRow().toFirstObj()); 90 | 91 | P("selectWhenE (id) = \"2\"", _tab1.selectWhenE(1, "2", 0, null).toFirstObj()); 92 | P("selectWhenE (id) = \"3\" and (id2) = \"21\"", _tab1.selectWhenE2(1, "3", "21", 1, 0).toFirstObj()); 93 | P("selectWhenE (id) = \"4\" and (id2) = \"21\" and (id3) = \"200\"", _tab1.selectWhenE3(1, "4", "21", "200", 2, 1, 0).toFirstObj()); 94 | P("selectWhenE ALL (id2) = \"20\"", _tab1.selectWhenE(0, "20", 1, null).toObjs()); 95 | P("merge tables", _tab1.merge(_tab1).selectAll().toRows()); 96 | } 97 | 98 | public static void test_enhanced_csv_format() 99 | { 100 | P("[E] select ALL to rows", _tab2.selectAll().toRows()); 101 | P("[E] select ALL to objs", _tab2.selectAll().toObjs()); 102 | P("[E] select first row", _tab2.selectFirstRow().toFirstRow()); 103 | P("[E] select first obj", _tab2.selectFirstRow().toFirstObj()); 104 | P("[E] select last row", _tab2.selectLastRow().toFirstRow()); 105 | P("[E] select last obj", _tab2.selectLastRow().toFirstObj()); 106 | 107 | P("[E] selectWhenE (id) = 2", _tab2.selectWhenE(1, 2, 0, null).toFirstObj()); 108 | P("[E] selectWhenE (id) = -1", _tab2.selectWhenE(1, -1, 0, null).toFirstObj()); 109 | P("[E] selectWhenE2 (id) = 3 and (id2) = 22", _tab2.selectWhenE2(1, 3, 22, 1, 0).toFirstObj()); 110 | P("[E] selectWhenE2 (id) = 3 and (id2) = -1", _tab2.selectWhenE2(1, 3, -1,1,0).toFirstObj()); 111 | P("[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = 200", _tab2.selectWhenE3(1, 4, 22, 200, 2, 1, 0).toFirstObj()); 112 | P("[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = -1", _tab2.selectWhenE3(1, 4, 22, -1, 2, 1, 0).toFirstObj()); 113 | P("[E] selectWhenE ALL (id2) = 21", _tab2.selectWhenE(0, 21, 1, null).toObjs()); 114 | P("[E] selectWhenE ALL (id2) = -1", _tab2.selectWhenE(0, -1, 1, null).toObjs()); 115 | 116 | P("[E] selectWhenG ALL (id2) > 25", _tab2.selectWhenG(0, false, 25, 1).toObjs()); 117 | P("[E] selectWhenG ALL (id2) >= 25", _tab2.selectWhenG(0, true, 25, 1).toObjs()); 118 | P("[E] selectWhenG ALL (id2) > 30", _tab2.selectWhenG(0, false, 30, 1).toObjs()); 119 | P("[E] selectWhenL ALL (id2) < 22", _tab2.selectWhenL(0, false, 22, 1).toObjs()); 120 | P("[E] selectWhenL ALL (id2) <= 22", _tab2.selectWhenL(0, true, 22, 1).toObjs()); 121 | P("[E] selectWhenL ALL (id2) < 20", _tab2.selectWhenL(0, true, 20, 1).toObjs()); 122 | P("[E] selectWhenGreaterAndLess ALL (id2) > 21 and (id2) < 24", _tab2.selectWhenGreaterAndLess(0, false, false, 21, 24, 1).toObjs()); 123 | P("[E] selectWhenGreaterAndLess ALL (id2) >= 21 and (id2) <= 24", _tab2.selectWhenGreaterAndLess(0, true, true, 21, 24, 1).toObjs()); 124 | P("[E] selectWhenLessOrGreater ALL (id2) < 22 or (id2) > 25", _tab2.selectWhenLessOrGreater(0, false, false, 22, 25, 1).toObjs()); 125 | P("[E] selectWhenLessOrGreater ALL (id2) <= 22 or (id2) >= 25", _tab2.selectWhenLessOrGreater(0, true, true, 22, 25, 1).toObjs()); 126 | P("[E] selectWhenIn (id) in 3,4,5", _tab2.selectWhenIn(1, new object[]{3,4,5},0).toObjs()); 127 | P("[E] selectAt rows at 0,1,10", _tab2.selectAt(new int[]{0,1,10}).toObjs()); 128 | 129 | P("[E] multi selects (id3) = 100 and (id2) < 22", _tab2.selectWhenE(0, 100, 2, null).selectWhenL(0, false, 22, 1).toObjs()); 130 | P("[E] sort by (id3) = 300 desc (id)", _tab2.selectWhenE(0, 300, 2, null).sortBy(0, 1).toObjs()); 131 | 132 | _tab2.createIndexAt(0); 133 | P("[E] (indexed) 1st row name", _tab2.selectWhenE(1, "Dwi", _tab2.getColIndexBy("name"), null).toObjs()[0]["name"]); 134 | P("[E] (indexed) id=6 education.CC", ((JObject)_tab2.id(6, 0)["education"])["CC"]); 135 | P("[E] (indexed) id=6 tags #2", ((JArray)_tab2.id(6, 0)["tags"])[1]); 136 | P("[E] (indexed) 99th row", _tab2.selectWhenE(1, 99, 0, null).toObjs()); 137 | } 138 | 139 | public static string readTostring(string fileName) 140 | { 141 | string text = File.ReadAllText(fileName); 142 | return text; 143 | } 144 | } -------------------------------------------------------------------------------- /src/typescript/Demo.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /** 3 | * Tables 4 | */ 5 | var _tab1: acsv.Table; 6 | var _tab2: acsv.Table; 7 | /** 8 | * Entry. 9 | */ 10 | function main() 11 | { 12 | var xhr = new XMLHttpRequest(); 13 | xhr.open("GET","../../release/csvs/standard_format_text.csv",false); 14 | xhr.send(); 15 | var standard_format_text = xhr.responseText; 16 | _tab1 = acsv.Table.Parse(standard_format_text); 17 | var xhr = new XMLHttpRequest(); 18 | xhr.open("GET","../../release/csvs/enhanced_format_text.csv",false); 19 | xhr.send(); 20 | var enhanced_format_text = xhr.responseText; 21 | _tab2 = acsv.Table.Parse(enhanced_format_text); 22 | 23 | showTable("standard csv format", _tab1); 24 | test_standard_csv_format(); 25 | showTable("[E] enhanced csv format", _tab2); 26 | test_enhanced_csv_format(); 27 | } 28 | 29 | function showTable(fileName: string, csvTable: acsv.Table): void 30 | { 31 | var t = document.getElementById('output'); 32 | var tab = document.createElement('table'); 33 | { 34 | var thead = document.createElement('thead'); 35 | var tr = document.createElement('tr'); 36 | thead.appendChild(tr); 37 | for (var i = 0; i < csvTable.head.length; i++) 38 | { 39 | var td = document.createElement('td'); 40 | var rowI = csvTable.head[i]; 41 | td.innerText = rowI.fullName; 42 | tr.appendChild(td); 43 | } 44 | tab.appendChild(thead); 45 | } 46 | { 47 | var tbody = document.createElement('tbody'); 48 | for (var i = 0; i < csvTable.body.length; i++) 49 | { 50 | var tr = document.createElement('tr'); 51 | var rows = csvTable.body[i]; 52 | for (var j = 0; j < rows.length; j++) 53 | { 54 | var td: HTMLTableCellElement = document.createElement('td'); 55 | var rowJ = rows[j]; 56 | td.innerText = rowJ; 57 | tr.appendChild(td); 58 | } 59 | tbody.appendChild(tr); 60 | } 61 | tab.appendChild(tbody); 62 | } 63 | { 64 | var tfoot = document.createElement('tfoot'); 65 | var tr = document.createElement('tr'); 66 | var td: HTMLTableCellElement = document.createElement('td'); 67 | td.colSpan = csvTable.head.length; 68 | td.innerText = fileName; 69 | tr.appendChild(td); 70 | tfoot.appendChild(tr); 71 | tab.appendChild(tfoot); 72 | } 73 | t.appendChild(tab); 74 | 75 | } 76 | function P(cmd: string, o: any): void 77 | { 78 | var t = document.getElementById('output'); 79 | var div = document.createElement('div'); 80 | var span = document.createElement('span'); 81 | span.innerHTML = cmd.replace('[E]', '[E]'); 82 | div.appendChild(span); 83 | div.title = JSON.stringify(o, null, '\t'); 84 | div.innerHTML += JSON.stringify(o); 85 | t.appendChild(div); 86 | 87 | console.log(cmd); 88 | if (o == null) // fix some language's bug 89 | { 90 | console.log(null); 91 | } 92 | else 93 | { 94 | console.log(o); 95 | } 96 | } 97 | function test_standard_csv_format() 98 | { 99 | P('select ALL to rows', _tab1.selectAll().toRows()); 100 | P('select ALL to objs', _tab1.selectAll().toObjs()); 101 | P('select first row', _tab1.selectFirstRow().toFirstRow()); 102 | P('select first obj', _tab1.selectFirstRow().toFirstObj()); 103 | P('select last row', _tab1.selectLastRow().toFirstRow()); 104 | P('select last obj', _tab1.selectLastRow().toFirstObj()); 105 | 106 | P('selectWhenE (id) = "2"', _tab1.selectWhenE(1, "2").toFirstObj()); 107 | P('selectWhenE (id) = "3" and (id2) = "21"', _tab1.selectWhenE2(1, "3", "21").toFirstObj()); 108 | P('selectWhenE (id) = "4" and (id2) = "21" and (id3) = "200"', _tab1.selectWhenE3(1, "4", "21", "200").toFirstObj()); 109 | P('selectWhenE ALL (id2) = "20"', _tab1.selectWhenE(0, "20", 1).toObjs()); 110 | P('merge tables', _tab1.merge(_tab1).selectAll().toRows()); 111 | } 112 | function test_enhanced_csv_format() 113 | { 114 | P('[E] select ALL to rows', _tab2.selectAll().toRows()); 115 | P('[E] select ALL to objs', _tab2.selectAll().toObjs()); 116 | P('[E] select first row', _tab2.selectFirstRow().toFirstRow()); 117 | P('[E] select first obj', _tab2.selectFirstRow().toFirstObj()); 118 | P('[E] select last row', _tab2.selectLastRow().toFirstRow()); 119 | P('[E] select last obj', _tab2.selectLastRow().toFirstObj()); 120 | 121 | P('[E] selectWhenE (id) = 2', _tab2.selectWhenE(1, 2).toFirstObj()); 122 | P('[E] selectWhenE (id) = -1', _tab2.selectWhenE(1, -1).toFirstObj()); 123 | P('[E] selectWhenE2 (id) = 3 and (id2) = 22', _tab2.selectWhenE2(1, 3, 22).toFirstObj()); 124 | P('[E] selectWhenE2 (id) = 3 and (id2) = -1', _tab2.selectWhenE2(1, 3, -1).toFirstObj()); 125 | P('[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = 200', _tab2.selectWhenE3(1, 4, 22, 200).toFirstObj()); 126 | P('[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = -1', _tab2.selectWhenE3(1, 4, 22, -1).toFirstObj()); 127 | P('[E] selectWhenE ALL (id2) = 21', _tab2.selectWhenE(0, 21, 1).toObjs()); 128 | P('[E] selectWhenE ALL (id2) = -1', _tab2.selectWhenE(0, -1, 1).toObjs()); 129 | 130 | P('[E] selectWhenG ALL (id2) > 25', _tab2.selectWhenG(0, false, 25, 1).toObjs()); 131 | P('[E] selectWhenG ALL (id2) >= 25', _tab2.selectWhenG(0, true, 25, 1).toObjs()); 132 | P('[E] selectWhenG ALL (id2) > 30', _tab2.selectWhenG(0, false, 30, 1).toObjs()); 133 | P('[E] selectWhenL ALL (id2) < 22', _tab2.selectWhenL(0, false, 22, 1).toObjs()); 134 | P('[E] selectWhenL ALL (id2) <= 22', _tab2.selectWhenL(0, true, 22, 1).toObjs()); 135 | P('[E] selectWhenL ALL (id2) < 20', _tab2.selectWhenL(0, true, 20, 1).toObjs()); 136 | P('[E] selectWhenGreaterAndLess ALL (id2) > 21 and (id2) < 24', _tab2.selectWhenGreaterAndLess(0, false, false, 21, 24, 1).toObjs()); 137 | P('[E] selectWhenGreaterAndLess ALL (id2) >= 21 and (id2) <= 24', _tab2.selectWhenGreaterAndLess(0, true, true, 21, 24, 1).toObjs()); 138 | P('[E] selectWhenLessOrGreater ALL (id2) < 22 or (id2) > 25', _tab2.selectWhenLessOrGreater(0, false, false, 22, 25, 1).toObjs()); 139 | P('[E] selectWhenLessOrGreater ALL (id2) <= 22 or (id2) >= 25', _tab2.selectWhenLessOrGreater(0, true, true, 22, 25, 1).toObjs()); 140 | P('[E] selectWhenIn (id) in 3,4,5', _tab2.selectWhenIn(1, [3,4,5]).toObjs()); 141 | P('[E] selectAt rows at 0,1,10', _tab2.selectAt([0,1,10]).toObjs()); 142 | 143 | P('[E] multi selects (id3) = 100 and (id2) < 22', _tab2.selectWhenE(0, 100, 2).selectWhenL(0, false, 22, 1).toObjs()); 144 | P('[E] sort by (id3) = 300 desc (id)', _tab2.selectWhenE(0, 300, 2).sortBy(0, 1).toObjs()); 145 | 146 | _tab2.createIndexAt(0); 147 | P("[E] (indexed) 1st row name", _tab2.selectWhenE(1, 'Dwi', _tab2.getColIndexBy('name')).toObjs()[0].name); 148 | P("[E] (indexed) id=6 education.CC", _tab2.id(6).education.CC); 149 | P("[E] (indexed) id=6 tags #2", _tab2.id(6).tags[1]); 150 | P('[E] (indexed) 99th row', _tab2.selectWhenE(1, 99).toObjs()); 151 | } 152 | main(); -------------------------------------------------------------------------------- /src/java/Demo.java: -------------------------------------------------------------------------------- 1 | import java.io.File; 2 | import java.io.FileInputStream; 3 | import java.io.FileNotFoundException; 4 | import java.io.IOException; 5 | import java.io.UnsupportedEncodingException; 6 | import java.nio.charset.Charset; 7 | import java.util.Arrays; 8 | import java.util.HashMap; 9 | 10 | import org.json.JSONArray; 11 | import org.json.JSONException; 12 | import org.json.JSONObject; 13 | 14 | import acsv.*; 15 | 16 | public class Demo 17 | { 18 | /** 19 | * Tables 20 | */ 21 | private static Table _tab1; 22 | private static Table _tab2; 23 | /** 24 | * Main Entry. 25 | * @return 26 | */ 27 | public static void main(String[] args) 28 | { 29 | System.out.println("Default charset=" + Charset.defaultCharset()); 30 | System.out.println(System.getProperty("user.dir")); 31 | System.out.println(); 32 | 33 | String standard_format_text = readToString("../../release/csvs/standard_format_text.csv"); 34 | _tab1 = Table.Parse(standard_format_text); 35 | test_standard_csv_format(); 36 | String enhanced_format_text = readToString("../../release/csvs/enhanced_format_text.csv"); 37 | _tab2 = Table.Parse(enhanced_format_text); 38 | try { 39 | test_enhanced_csv_format(); 40 | } catch (JSONException e) { 41 | e.printStackTrace(); 42 | } 43 | } 44 | 45 | public static void P(String cmd, Object o) 46 | { 47 | System.out.println(cmd); 48 | if (o == null) 49 | { 50 | System.out.println("null"); 51 | } 52 | else if (o instanceof HashMap) 53 | { 54 | System.out.println(o); 55 | } 56 | else if (o instanceof Object[]) 57 | { 58 | System.out.println(Arrays.deepToString((Object[]) o)); 59 | } 60 | else 61 | { 62 | System.out.println(o); 63 | } 64 | System.out.println(); 65 | } 66 | 67 | public static void test_standard_csv_format() 68 | { 69 | P("select ALL to rows", _tab1.selectAll().toRows()); 70 | P("select ALL to objs", _tab1.selectAll().toObjs()); 71 | P("select first row", _tab1.selectFirstRow().toFirstRow()); 72 | P("select first obj", _tab1.selectFirstRow().toFirstObj()); 73 | P("select last row", _tab1.selectLastRow().toFirstRow()); 74 | P("select last obj", _tab1.selectLastRow().toFirstObj()); 75 | 76 | P("selectWhenE (id) = \"2\"", _tab1.selectWhenE(1, "2", 0, null).toFirstObj()); 77 | P("selectWhenE (id) = \"3\" and (id2) = \"21\"", _tab1.selectWhenE2(1, "3", "21", 1, 0).toFirstObj()); 78 | P("selectWhenE (id) = \"4\" and (id2) = \"21\" and (id3) = \"200\"", _tab1.selectWhenE3(1, "4", "21", "200", 2, 1, 0).toFirstObj()); 79 | P("selectWhenE ALL (id2) = \"20\"", _tab1.selectWhenE(0, "20", 1, null).toObjs()); 80 | P("merge tables", _tab1.merge(_tab1).selectAll().toRows()); 81 | } 82 | 83 | public static void test_enhanced_csv_format() throws JSONException 84 | { 85 | P("[E] select ALL to rows", _tab2.selectAll().toRows()); 86 | P("[E] select ALL to objs", _tab2.selectAll().toObjs()); 87 | P("[E] select first row", _tab2.selectFirstRow().toFirstRow()); 88 | P("[E] select first obj", _tab2.selectFirstRow().toFirstObj()); 89 | P("[E] select last row", _tab2.selectLastRow().toFirstRow()); 90 | P("[E] select last obj", _tab2.selectLastRow().toFirstObj()); 91 | 92 | P("[E] selectWhenE (id) = 2", _tab2.selectWhenE(1, 2, 0, null).toFirstObj()); 93 | P("[E] selectWhenE (id) = -1", _tab2.selectWhenE(1, -1, 0, null).toFirstObj()); 94 | P("[E] selectWhenE2 (id) = 3 and (id2) = 22", _tab2.selectWhenE2(1, 3, 22, 1, 0).toFirstObj()); 95 | P("[E] selectWhenE2 (id) = 3 and (id2) = -1", _tab2.selectWhenE2(1, 3, -1,1,0).toFirstObj()); 96 | P("[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = 200", _tab2.selectWhenE3(1, 4, 22, 200, 2, 1, 0).toFirstObj()); 97 | P("[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = -1", _tab2.selectWhenE3(1, 4, 22, -1, 2, 1, 0).toFirstObj()); 98 | P("[E] selectWhenE ALL (id2) = 21", _tab2.selectWhenE(0, 21, 1, null).toObjs()); 99 | P("[E] selectWhenE ALL (id2) = -1", _tab2.selectWhenE(0, -1, 1, null).toObjs()); 100 | 101 | P("[E] selectWhenG ALL (id2) > 25", _tab2.selectWhenG(0, false, 25, 1).toObjs()); 102 | P("[E] selectWhenG ALL (id2) >= 25", _tab2.selectWhenG(0, true, 25, 1).toObjs()); 103 | P("[E] selectWhenG ALL (id2) > 30", _tab2.selectWhenG(0, false, 30, 1).toObjs()); 104 | P("[E] selectWhenL ALL (id2) < 22", _tab2.selectWhenL(0, false, 22, 1).toObjs()); 105 | P("[E] selectWhenL ALL (id2) <= 22", _tab2.selectWhenL(0, true, 22, 1).toObjs()); 106 | P("[E] selectWhenL ALL (id2) < 20", _tab2.selectWhenL(0, true, 20, 1).toObjs()); 107 | P("[E] selectWhenGreaterAndLess ALL (id2) > 21 and (id2) < 24", _tab2.selectWhenGreaterAndLess(0, false, false, 21, 24, 1).toObjs()); 108 | P("[E] selectWhenGreaterAndLess ALL (id2) >= 21 and (id2) <= 24", _tab2.selectWhenGreaterAndLess(0, true, true, 21, 24, 1).toObjs()); 109 | P("[E] selectWhenLessOrGreater ALL (id2) < 22 or (id2) > 25", _tab2.selectWhenLessOrGreater(0, false, false, 22, 25, 1).toObjs()); 110 | P("[E] selectWhenLessOrGreater ALL (id2) <= 22 or (id2) >= 25", _tab2.selectWhenLessOrGreater(0, true, true, 22, 25, 1).toObjs()); 111 | P("[E] selectWhenIn (id) in 3,4,5", _tab2.selectWhenIn(1, new Object[]{3,4,5},0).toObjs()); 112 | P("[E] selectAt rows at 0,1,10", _tab2.selectAt(new int[]{0,1,10}).toObjs()); 113 | 114 | P("[E] multi selects (id3) = 100 and (id2) < 22", _tab2.selectWhenE(0, 100, 2, null).selectWhenL(0, false, 22, 1).toObjs()); 115 | P("[E] sort by (id3) = 300 desc (id)", _tab2.selectWhenE(0, 300, 2, null).sortBy(0, 1).toObjs()); 116 | 117 | _tab2.createIndexAt(0); 118 | P("[E] (indexed) 1st row name", _tab2.selectWhenE(1, "Dwi", _tab2.getColIndexBy("name"), null).toObjs()[0].get("name")); 119 | P("[E] (indexed) id=6 education.CC", ((JSONObject)_tab2.id(6, 0).get("education")).getString("CC") ); 120 | P("[E] (indexed) id=6 tags #2", ((JSONArray)_tab2.id(6, 0).get("tags")).get(1) ); 121 | P("[E] (indexed) 99th row", _tab2.selectWhenE(1, 99, 0, null).toObjs()); 122 | } 123 | 124 | public static String readToString(String fileName) 125 | { 126 | String encoding = "UTF-8"; 127 | File file = new File(fileName); 128 | Long filelength = file.length(); 129 | byte[] filecontent = new byte[filelength.intValue()]; 130 | try 131 | { 132 | FileInputStream in = new FileInputStream(file); 133 | in.read(filecontent); 134 | in.close(); 135 | } 136 | catch (FileNotFoundException e) 137 | { 138 | e.printStackTrace(); 139 | } catch (IOException e) 140 | { 141 | e.printStackTrace(); 142 | } 143 | try 144 | { 145 | return new String(filecontent, encoding); 146 | } 147 | catch (UnsupportedEncodingException e) 148 | { 149 | System.err.println("The OS does not support " + encoding); 150 | e.printStackTrace(); 151 | return null; 152 | } 153 | } 154 | } -------------------------------------------------------------------------------- /release/docs/hx/Array.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Array - ACsv library

An Array is a storage for values. You can access it using indexes or 11 | with its API.

See:

Constructor

new()

Creates a new Array.

Variables

read onlylength:Int

The length of this Array.

Methods

concat(a:Array<T>):Array<T>

Returns a new Array by appending the elements of a to the elements of 12 | this Array.

13 |

This operation does not modify this Array.

14 |

If a is the empty Array [], a copy of this Array is returned.

15 |

The length of the returned Array is equal to the sum of this.length 16 | and a.length.

17 |

If a is null, the result is unspecified.

indexOf(x:T, ?fromIndex:Int):Int

Returns position of the first occurrence of x in this Array, searching front to back.

18 |

If x is found by checking standard equality, the function returns its index.

19 |

If x is not found, the function returns -1.

20 |

If fromIndex is specified, it will be used as the starting index to search from, 21 | otherwise search starts with zero index. If it is negative, it will be taken as the 22 | offset from the end of this Array to compute the starting index. If given or computed 23 | starting index is less than 0, the whole array will be searched, if it is greater than 24 | or equal to the length of this Array, the function returns -1.

join(sep:String):String

Returns a string representation of this Array, with sep separating 25 | each element.

26 |

The result of this operation is equal to Std.string(this[0]) + sep + 27 | Std.string(this[1]) + sep + ... + sep + Std.string(this[this.length-1])

28 |

If this is the empty Array [], the result is the empty String "". 29 | If this has exactly one element, the result is equal to a call to 30 | Std.string(this[0]).

31 |

If sep is null, the result is unspecified.

push(x:T):Int

Adds the element x at the end of this Array and returns the new 32 | length of this Array.

33 |

This operation modifies this Array in place.

34 |

this.length increases by 1.

shift():Null<T>

Removes the first element of this Array and returns it.

35 |

This operation modifies this Array in place.

36 |

If this has at least one element, this.length and the index of each 37 | remaining element is decreased by 1.

38 |

If this is the empty Array [], null is returned and the length 39 | remains 0.

-------------------------------------------------------------------------------- /src/haxe/Demo.hx: -------------------------------------------------------------------------------- 1 | package ; 2 | 3 | import acsv.*; 4 | 5 | class Demo 6 | { 7 | /** 8 | * Standard csv format text 9 | */ 10 | public static var standard_format_text = 'id,id2,id3,name,brief 11 | 1,20,100,John,He is a googd man 12 | 2,20,100,张三,"他是一个好人 13 | 我们都喜欢他" 14 | 3,21,100,море,"Он хороший человек 15 | мы все любим его 16 | Его девиз: 17 | ""доверяй себе""" 18 | 4,21,200,الشمس,صباح الخير 19 | 5,22,200,चंद्रमा,सुसंध्या 20 | 6,22,200,ดาว,'; 21 | /** 22 | * Enhanced csv format text 23 | */ 24 | public static var enhanced_format_text = 'id:int,id2:int,id3:int,name:string,weight:number,marry:bool,education:json,tags:strings,brief 25 | 1,21,100,John,120.1,true,"[""AB""]","good,cool","Today is good day 26 | Tomorrow is good day too" 27 | 2,21,100,张三,121.2,false,"[""CD"",""EF""]",good,今天是个好日子 28 | 3,22,100,море,123.4,true,"[""GH"",""AB"",""CD""]",good,"Сегодня хороший день 29 | ""Завтра тоже хороший день""" 30 | 4,22,200,الشمس,124.5,false,"{""AA"":12}",strong,صباح الخير 31 | 5,23,200,चंद्रमा,126.7,1,"{""BB"":12}",strong,सुसंध्या 32 | 6,23,200,Emilia,,0,"{""CC"":67,""DD"":56}","strong,cool",Hoje é um bom dia 33 | 7,24,300,Ayşe,128.9,0,"{""EE"":68,""FF"":56}","strong,cool",Bugün güzel bir gün 34 | 8,24,300,陽菜乃,129.01,,"{""AC"":78,""BD"":[90,12]}","height,strong",今日はいい日です 35 | 9,25,300,Dwi,130.12,1,"{""EF"":78,""CF"":[90,12]}",,"Hari ini adalah hari yang baik 36 | Besok juga hari yang baik" 37 | 10,25,400,Bảo,131.23,1,"[""BC"",{""AT"":34}]","thin,good", 38 | 11,26,400,민준,132.34,0,"[""FG"",{""AG"":34}]","hot,thin,good",오늘은 좋은 날이다 39 | 12,26,400,ดาว,133.456,0,,,'; 40 | /** 41 | * Tables 42 | */ 43 | private static var _tab1:Table; 44 | private static var _tab2:Table; 45 | /** 46 | * Main Entry. 47 | */ 48 | public static function main() 49 | { 50 | #if js 51 | var xhr = new js.html.XMLHttpRequest(); 52 | xhr.open("GET","../../release/csvs/standard_format_text.csv",false); 53 | xhr.send(); 54 | var standard_format_text = xhr.responseText; 55 | _tab1 = acsv.Table.Parse(standard_format_text); 56 | var xhr = new js.html.XMLHttpRequest(); 57 | xhr.open("GET","../../release/csvs/enhanced_format_text.csv",false); 58 | xhr.send(); 59 | var enhanced_format_text = xhr.responseText; 60 | _tab2 = acsv.Table.Parse(enhanced_format_text); 61 | #else 62 | _tab1 = Table.Parse(standard_format_text); 63 | _tab2 = Table.Parse(enhanced_format_text); 64 | #end 65 | showTable("standard csv format", _tab1); 66 | test_standard_csv_format(); 67 | showTable("[E] enhanced csv format", _tab2); 68 | test_enhanced_csv_format(); 69 | } 70 | 71 | private static function showTable(fileName:String, csvTable:Table):Void 72 | { 73 | #if js 74 | var t = js.Browser.document.getElementById('output'); 75 | var tab = js.Browser.document.createElement('table'); 76 | { 77 | var thead = js.Browser.document.createElement('thead'); 78 | var tr = js.Browser.document.createElement('tr'); 79 | thead.appendChild(tr); 80 | for(i in 0...csvTable.head.length) 81 | { 82 | var td = js.Browser.document.createElement('td'); 83 | var rowI = csvTable.head[i]; 84 | td.innerText = rowI.fullName; 85 | tr.appendChild(td); 86 | } 87 | tab.appendChild(thead); 88 | } 89 | { 90 | var tbody = js.Browser.document.createElement('tbody'); 91 | for(i in 0...csvTable.body.length) 92 | { 93 | var tr = js.Browser.document.createElement('tr'); 94 | var rows = csvTable.body[i]; 95 | for(j in 0...rows.length) 96 | { 97 | var td = js.Browser.document.createElement('td'); 98 | var rowJ = rows[j]; 99 | td.innerText = rowJ; 100 | tr.appendChild(td); 101 | } 102 | tbody.appendChild(tr); 103 | } 104 | tab.appendChild(tbody); 105 | } 106 | { 107 | var tfoot = js.Browser.document.createElement('tfoot'); 108 | var tr = js.Browser.document.createElement('tr'); 109 | var td:js.html.TableCellElement = untyped js.Browser.document.createElement('td'); 110 | td.colSpan = csvTable.head.length; 111 | td.innerText = fileName; 112 | tr.appendChild(td); 113 | tfoot.appendChild(tr); 114 | tab.appendChild(tfoot); 115 | } 116 | t.appendChild(tab); 117 | #end 118 | 119 | } 120 | public static function P(cmd:String, o:Dynamic):Void 121 | { 122 | #if js 123 | var t = js.Browser.document.getElementById('output'); 124 | var div = js.Browser.document.createElement('div'); 125 | var span = js.Browser.document.createElement('span'); 126 | span.innerHTML = StringTools.replace(cmd, '[E]', '[E]'); 127 | div.appendChild(span); 128 | div.title = haxe.Json.stringify(o, null, '\t'); 129 | div.innerHTML += haxe.Json.stringify(o); 130 | t.appendChild(div); 131 | #end 132 | trace(cmd); 133 | if (o == null) // fix some language's bug 134 | { 135 | trace(null); 136 | } 137 | else 138 | { 139 | trace(o); 140 | } 141 | } 142 | 143 | public static function test_standard_csv_format() 144 | { 145 | P('select ALL to rows', _tab1.selectAll().toRows()); 146 | P('select ALL to objs', _tab1.selectAll().toObjs()); 147 | P('select first row', _tab1.selectFirstRow().toFirstRow()); 148 | P('select first obj', _tab1.selectFirstRow().toFirstObj()); 149 | P('select last row', _tab1.selectLastRow().toFirstRow()); 150 | P('select last obj', _tab1.selectLastRow().toFirstObj()); 151 | 152 | P('selectWhenE (id) = "2"', _tab1.selectWhenE(1, "2").toFirstObj()); 153 | P('selectWhenE (id) = "3" and (id2) = "21"', _tab1.selectWhenE2(1, "3", "21").toFirstObj()); 154 | P('selectWhenE (id) = "4" and (id2) = "21" and (id3) = "200"', _tab1.selectWhenE3(1, "4", "21", "200").toFirstObj()); 155 | P('selectWhenE ALL (id2) = "20"', _tab1.selectWhenE(0, "20", 1).toObjs()); 156 | P('merge tables', _tab1.merge(_tab1).selectAll().toRows()); 157 | } 158 | 159 | public static function test_enhanced_csv_format() 160 | { 161 | P('[E] select ALL to rows', _tab2.selectAll().toRows()); 162 | P('[E] select ALL to objs', _tab2.selectAll().toObjs()); 163 | P('[E] select first row', _tab2.selectFirstRow().toFirstRow()); 164 | P('[E] select first obj', _tab2.selectFirstRow().toFirstObj()); 165 | P('[E] select last row', _tab2.selectLastRow().toFirstRow()); 166 | P('[E] select last obj', _tab2.selectLastRow().toFirstObj()); 167 | 168 | P('[E] selectWhenE (id) = 2', _tab2.selectWhenE(1, 2).toFirstObj()); 169 | P('[E] selectWhenE (id) = -1', _tab2.selectWhenE(1, -1).toFirstObj()); 170 | P('[E] selectWhenE2 (id) = 3 and (id2) = 22', _tab2.selectWhenE2(1, 3, 22).toFirstObj()); 171 | P('[E] selectWhenE2 (id) = 3 and (id2) = -1', _tab2.selectWhenE2(1, 3, -1).toFirstObj()); 172 | P('[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = 200', _tab2.selectWhenE3(1, 4, 22, 200).toFirstObj()); 173 | P('[E] selectWhenE3 (id) = 4 and (id2) = 22 and (id3) = -1', _tab2.selectWhenE3(1, 4, 22, -1).toFirstObj()); 174 | P('[E] selectWhenE ALL (id2) = 21', _tab2.selectWhenE(0, 21, 1).toObjs()); 175 | P('[E] selectWhenE ALL (id2) = -1', _tab2.selectWhenE(0, -1, 1).toObjs()); 176 | 177 | P('[E] selectWhenG ALL (id2) > 25', _tab2.selectWhenG(0, false, 25, 1).toObjs()); 178 | P('[E] selectWhenG ALL (id2) >= 25', _tab2.selectWhenG(0, true, 25, 1).toObjs()); 179 | P('[E] selectWhenG ALL (id2) > 30', _tab2.selectWhenG(0, false, 30, 1).toObjs()); 180 | P('[E] selectWhenL ALL (id2) < 22', _tab2.selectWhenL(0, false, 22, 1).toObjs()); 181 | P('[E] selectWhenL ALL (id2) <= 22', _tab2.selectWhenL(0, true, 22, 1).toObjs()); 182 | P('[E] selectWhenL ALL (id2) < 20', _tab2.selectWhenL(0, true, 20, 1).toObjs()); 183 | P('[E] selectWhenGreaterAndLess ALL (id2) > 21 and (id2) < 24', _tab2.selectWhenGreaterAndLess(0, false, false, 21, 24, 1).toObjs()); 184 | P('[E] selectWhenGreaterAndLess ALL (id2) >= 21 and (id2) <= 24', _tab2.selectWhenGreaterAndLess(0, true, true, 21, 24, 1).toObjs()); 185 | P('[E] selectWhenLessOrGreater ALL (id2) < 22 or (id2) > 25', _tab2.selectWhenLessOrGreater(0, false, false, 22, 25, 1).toObjs()); 186 | P('[E] selectWhenLessOrGreater ALL (id2) <= 22 or (id2) >= 25', _tab2.selectWhenLessOrGreater(0, true, true, 22, 25, 1).toObjs()); 187 | P('[E] selectWhenIn (id) in 3,4,5', _tab2.selectWhenIn(1, [3,4,5]).toObjs()); 188 | P('[E] selectAt rows at 0,1,10', _tab2.selectAt([0,1,10]).toObjs()); 189 | 190 | P('[E] multi selects (id3) = 100 and (id2) < 22', _tab2.selectWhenE(0, 100, 2).selectWhenL(0, false, 22, 1).toObjs()); 191 | P('[E] sort by (id3) = 300 desc (id)', _tab2.selectWhenE(0, 300, 2).sortBy(0, 1).toObjs()); 192 | 193 | _tab2.createIndexAt(0); 194 | P("[E] (indexed) 1st row name", _tab2.selectWhenE(1, 'Dwi', _tab2.getColIndexBy('name')).toObjs()[0].name); 195 | P("[E] (indexed) id=6 education.CC", _tab2.id(6).education.CC); 196 | P("[E] (indexed) id=6 tags #2", _tab2.id(6).tags[1]); 197 | P("[E] (indexed) 99th row", _tab2.selectWhenE(1, 99).toObjs()); 198 | } 199 | } -------------------------------------------------------------------------------- /release/docs/hx/index.js: -------------------------------------------------------------------------------- 1 | function createCookie(name, value, days) { 2 | localStorage.setItem(name, value); 3 | } 4 | 5 | function readCookie(name) { 6 | return localStorage.getItem(name); 7 | } 8 | 9 | function toggleInherited(el) { 10 | var toggle = $(el).closest(".toggle"); 11 | toggle.toggleClass("toggle-on"); 12 | if (toggle.hasClass("toggle-on")) { 13 | $("i", toggle).removeClass("fa-arrow-circle-right").addClass("fa-arrow-circle-down"); 14 | } else { 15 | $("i", toggle).addClass("fa-arrow-circle-right").removeClass("fa-arrow-circle-down"); 16 | } 17 | return false; 18 | } 19 | 20 | function toggleCollapsed(el) { 21 | var toggle = $(el).closest(".expando"); 22 | toggle.toggleClass("expanded"); 23 | 24 | if (toggle.hasClass("expanded")) { 25 | $(toggle).find("i").first().removeClass("fa-arrow-circle-right").addClass("fa-arrow-circle-down"); 26 | } else { 27 | $(toggle).find("i").first().addClass("fa-arrow-circle-right").removeClass("fa-arrow-circle-down"); 28 | } 29 | updateTreeState(); 30 | return false; 31 | } 32 | 33 | function updateTreeState() { 34 | var states = []; 35 | $("#nav .expando").each(function (i, e) { 36 | states.push($(e).hasClass("expanded") ? 1 : 0); 37 | }); 38 | var treeState = JSON.stringify(states); 39 | createCookie("treeState", treeState); 40 | } 41 | 42 | var filters = {}; 43 | 44 | function selectVersion(e) { 45 | setVersion($(e.target).parent().attr("data")); 46 | } 47 | 48 | function setPlatform(platform) { 49 | createCookie("platform", platform); 50 | $("#select-platform").val(platform); 51 | 52 | var styles = ".platform { display:none }"; 53 | var platforms = dox.platforms; 54 | if (platform == "flash" || platform == "js") { 55 | styles += ".package-sys { display:none; } "; 56 | } 57 | for (var i = 0; i < platforms.length; i++) { 58 | var p = platforms[i]; 59 | if (platform == "sys") { 60 | if (p != "flash" && p != "js") { 61 | styles += ".platform-" + p + " { display:inherit } "; 62 | } 63 | } 64 | else { 65 | if (platform == "all" || p == platform) { 66 | styles += ".platform-" + p + " { display:inherit } "; 67 | } 68 | } 69 | } 70 | 71 | if (platform != "flash" && platform != "js") { 72 | styles += ".platform-sys { display:inherit } "; 73 | } 74 | 75 | $("#dynamicStylesheet").text(styles); 76 | } 77 | /* 78 | function setVersion(version) { 79 | createCookie("version", version); 80 | } 81 | */ 82 | 83 | $(document).ready(function () { 84 | $("#nav").html(navContent); 85 | var treeState = readCookie("treeState"); 86 | 87 | $("#nav .expando").each(function (i, e) { 88 | $("i", e).first().addClass("fa-arrow-circle-right").removeClass("fa-arrow-circle-down"); 89 | }); 90 | 91 | $(".treeLink").each(function () { 92 | this.href = this.href.replace("::rootPath::", dox.rootPath); 93 | }); 94 | 95 | if (treeState != null) { 96 | var states = JSON.parse(treeState); 97 | $("#nav .expando").each(function (i, e) { 98 | if (states[i]) { 99 | $(e).addClass("expanded"); 100 | $("i", e).first().removeClass("fa-arrow-circle-right").addClass("fa-arrow-circle-down"); 101 | } 102 | }); 103 | } 104 | $("head").append(""); 105 | 106 | setPlatform(readCookie("platform") == null ? "all" : readCookie("platform")); 107 | //setVersion(readCookie("version") == null ? "3_0" : readCookie("version")); 108 | 109 | $("#search").on("input", function (e) { 110 | searchQuery(e.target.value); 111 | }); 112 | $(document).bind("keyup keydown", function (e) { 113 | if (e.ctrlKey && e.keyCode == 80) { // ctrl + p 114 | $("#search").focus(); 115 | return false; 116 | } 117 | return true; 118 | }); 119 | function getItems() { 120 | return $("#search-results-list a").toArray(); 121 | } 122 | $("#search").bind("keyup", function (e) { 123 | switch (e.keyCode) { 124 | case 27: // escape 125 | searchQuery(""); 126 | $("#search").val("") 127 | $("#search").blur(); 128 | return false; 129 | 130 | case 13: // enter 131 | var items = getItems(); 132 | for (i = 0; i < items.length; i++) { 133 | var item = $(items[i]); 134 | if (item.hasClass("selected")) { 135 | window.location = items[i].href; 136 | break; 137 | } 138 | } 139 | return false; 140 | } 141 | }); 142 | $("#search").bind("keydown", function (e) { 143 | function mod(a, b) { 144 | var r = a % b; 145 | return r < 0 ? r + b : r; 146 | } 147 | function changeSelection(amount) { 148 | var previousSelection = null; 149 | var items = getItems(); 150 | for (i = 0; i < items.length; i++) { 151 | var item = $(items[i]); 152 | if (item.hasClass("selected")) { 153 | item.removeClass("selected"); 154 | previousSelection = i; 155 | break; 156 | } 157 | } 158 | var newSelection = mod(previousSelection + amount, items.length); 159 | $(items[newSelection]).addClass("selected"); 160 | items[newSelection].scrollIntoView(false); 161 | } 162 | switch (e.keyCode) { 163 | case 38: // up 164 | changeSelection(-1); 165 | return false; 166 | 167 | case 40: // down 168 | changeSelection(1); 169 | return false; 170 | 171 | case 13: // enter 172 | return false; 173 | } 174 | }); 175 | 176 | $("#select-platform").selectpicker().on("change", function (e) { 177 | var value = $(":selected", this).val(); 178 | setPlatform(value); 179 | }); 180 | 181 | $("#nav a").each(function () { 182 | if (this.href == location.href) { 183 | $(this.parentElement).addClass("active"); 184 | } 185 | }); 186 | 187 | $("a.expand-button").click(function (e) { 188 | var container = $(this).parent().next(); 189 | container.toggle(); 190 | $("i", this).removeClass("fa-arrow-circle-down") 191 | .removeClass("fa-arrow-circle-right") 192 | .addClass(container.is(":visible") ? "fa-arrow-circle-down" : "fa-arrow-circle-right"); 193 | return false; 194 | }); 195 | 196 | // Because there is no CSS parent selector 197 | $("code.prettyprint").parents("pre").addClass("example"); 198 | }); 199 | 200 | function searchQuery(query) { 201 | $("#searchForm").removeAttr("action"); 202 | query = query.replace(/[&<>"']/g, ""); 203 | if (!query || query.length < 2) { 204 | $("#nav").removeClass("searching"); 205 | $("#nav li").each(function (index, element) { 206 | var e = $(element); 207 | e.css("display", ""); 208 | }); 209 | $("#nav ul:first-child").css("display", "block"); 210 | $("#search-results-list").css("display", "none"); 211 | return; 212 | } 213 | var queryParts = query.toLowerCase().split(" "); 214 | var listItems = []; 215 | var bestMatch = 200; 216 | $("#nav").addClass("searching"); 217 | $("#nav ul:first-child").css("display", "none"); 218 | $("#nav li").each(function (index, element) { 219 | var e = $(element); 220 | if (!e.hasClass("expando")) { 221 | var content = e.attr("data_path"); 222 | var score = searchMatch(content, queryParts); 223 | if (score >= 0) { 224 | if (score < bestMatch) { 225 | var url = dox.rootPath + e.attr("data_path").split(".").join("/") + ".html"; 226 | $("#searchForm").attr("action", url); 227 | // best match will be form action 228 | bestMatch = score; 229 | } 230 | 231 | var elLink = $("a", element); 232 | // highlight matched parts 233 | var elLinkContent = elLink.text().replace(new RegExp("(" + queryParts.join("|").split(".").join("|") + ")", "ig"), "$1"); 234 | var liStyle = (score == 0) ? ("font-weight:bold") : ""; 235 | listItems.push({ score: score, item: "
  • " + elLinkContent + "
  • " }); 236 | } 237 | } 238 | }); 239 | if ($("#search-results-list").length == 0) { 240 | // append to nav 241 | $("#nav").parent().append(""); 242 | } 243 | listItems.sort(function (x, y) { return x.score - y.score; }); // put in order 244 | $("#search-results-list").css("display", "block").html(listItems.map(function (x) { return x.item; }).join("")); 245 | // pre-select the first item 246 | $("#search-results-list a").removeClass("selected"); 247 | $("#search-results-list a:first").addClass("selected"); 248 | } 249 | 250 | function match(textParts, query) { 251 | var queryParts = query.split("."); 252 | if (queryParts.length == 1) { 253 | var queryPart = queryParts[0]; 254 | for (var i = 0; i < textParts.length; ++i) { 255 | var textPart = textParts[i]; 256 | if (textPart.indexOf(queryPart) > -1) { 257 | // We don't want to match the same part twice, so let's remove it 258 | textParts[i] = textParts[i].split(queryPart).join(""); 259 | return textPart.length - queryPart.length; 260 | } 261 | } 262 | } else { 263 | var offset = -1; 264 | outer: 265 | while (true) { 266 | ++offset; 267 | if (queryParts.length + offset > textParts.length) { 268 | return -1; 269 | } 270 | var scoreSum = 0; 271 | for (var i = 0; i < queryParts.length; ++i) { 272 | var queryPart = queryParts[i]; 273 | var textPart = textParts[i + offset]; 274 | var index = textPart.indexOf(queryPart); 275 | if (index != 0) { 276 | continue outer; 277 | } 278 | scoreSum += textPart.length - queryPart.length; 279 | } 280 | return scoreSum; 281 | } 282 | } 283 | } 284 | 285 | function searchMatch(text, queryParts) { 286 | text = text.toLowerCase(); 287 | var textParts = text.split("."); 288 | var scoreSum = 0; 289 | for (var i = 0; i < queryParts.length; ++i) { 290 | var score = match(textParts, queryParts[i]); 291 | if (score == -1) { 292 | return -1; 293 | } 294 | scoreSum += score + text.length; 295 | } 296 | return scoreSum; 297 | } 298 | 299 | function errorSearch() { 300 | var errorURL = ""; 301 | if (!!window.location.pathname) { 302 | errorURL = window.location.pathname; 303 | } else if (!!window.location.href) { 304 | errorURL = window.location.href; 305 | } 306 | if (!!errorURL) { 307 | var searchTerm = errorURL.split("/").pop(); 308 | if (searchTerm.indexOf(".html") > -1) { searchTerm = searchTerm.split(".html").join(""); } 309 | if (!!searchTerm) { 310 | // update filter with search term 311 | $("#search").val(searchTerm); 312 | searchQuery(searchTerm); 313 | } 314 | } 315 | } -------------------------------------------------------------------------------- /src/typescript/ACsv.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace acsv 2 | { 3 | class Field 4 | { 5 | /** 6 | * Full Name. 7 | */ 8 | fullName: string; 9 | /** 10 | * Name. 11 | */ 12 | name: string; 13 | /** 14 | * Type. 15 | */ 16 | type: string; 17 | } 18 | /** 19 | * 1. Copyright (c) 2022 amin2312 20 | * 2. Version 1.0.0 21 | * 3. MIT License 22 | * 23 | * ACsv is a easy, fast and powerful csv parse library. 24 | */ 25 | class Table 26 | { 27 | /** 28 | * The raw content. 29 | */ 30 | content: number; 31 | /** 32 | * Parsed csv table Head. 33 | */ 34 | head: Array; 35 | /** 36 | * Parsed csv table Body. 37 | */ 38 | body: Array>; 39 | /** 40 | * Merge a table. 41 | *
    Notice: two tables' structure must be same. 42 | * @param b source table 43 | * @return THIS instance 44 | */ 45 | merge(b: Table): Table; 46 | /** 47 | * Create index for the specified column. 48 | *
    This function is only valid for "selectWhenE" and "limit" param is 1. 49 | *
    It will improve performance. 50 | * @param colIndex column index 51 | */ 52 | createIndexAt(colIndex: number): void; 53 | /** 54 | * Get column index by specified field name. 55 | * @param name As name mean 56 | * @return column index 57 | */ 58 | getColIndexBy(name: String): number; 59 | /** 60 | * Fetch a row object when the column's value is equal to the id value 61 | * @param values the specified value 62 | * @param colIndex specified column index 63 | * @return selected row object 64 | */ 65 | id(value: any, colIndex?: number): any; 66 | /** 67 | * Sort by selected rows. 68 | * @param colIndex the column index specified for sorting 69 | * @param sortType 0: asc, 1: desc 70 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 71 | */ 72 | sortBy(colIndex: number, sortType: number): Table; 73 | /** 74 | * Get current selector(it includes all selected results). 75 | *
    Notice: It be assigned after call "select..." function 76 | * @return current selector 77 | */ 78 | getCurrentSelector(): Array; 79 | /** 80 | * Fetch first selected result to a row and return it. 81 | * @return first selected row data 82 | */ 83 | toFirstRow(): Array; 84 | /** 85 | * Fetch last selected result to a row and return it. 86 | * @return last selected row data 87 | */ 88 | toLastRow(): Array; 89 | /** 90 | * Fetch all selected results to the rows and return it. 91 | * @return a array of row data 92 | */ 93 | toRows(): Array>; 94 | /** 95 | * Fetch first selected result to a object and return it. 96 | * @return first selected row object 97 | */ 98 | toFirstObj(): any; 99 | /** 100 | * Fetch last selected result to a object and return it. 101 | * @return last selected row object 102 | */ 103 | toLastObj(): any; 104 | /** 105 | * Fetch all selected results to the objects and return it. 106 | * @return a array of row object 107 | */ 108 | toObjs(): Array; 109 | /** 110 | * Fetch all selected results to a new table. 111 | * @return a new table instance 112 | */ 113 | toTable(): Table; 114 | /** 115 | * Select all rows. 116 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 117 | */ 118 | selectAll(): Table; 119 | /** 120 | * Select the first row. 121 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 122 | */ 123 | selectFirstRow(): Table; 124 | /** 125 | * Select the last row. 126 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 127 | */ 128 | selectLastRow(): Table 129 | /** 130 | * Selects the specified rows by indices. 131 | * @param rowIndices specified row's indices 132 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 133 | */ 134 | selectAt(rowIndices: Array): Table 135 | /** 136 | * Select the rows when the column's value is equal to any value of array. 137 | * @param limit maximum length of every selected results (0 is infinite, if you only need 1 result, 1 is recommended, it will improve performance) 138 | * @param values the array of values 139 | * @param colIndex specified column index 140 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 141 | */ 142 | selectWhenIn(limit: number, values: Array, colIndex?: number): Table 143 | /** 144 | * Select the rows when the column's value is equal to specified value. 145 | * @param limit maximum length of selected results (0 is infinite, if you only need 1 result, 1 is recommended, it will improve performance) 146 | * @param value the specified value 147 | * @param colIndex specified column index 148 | * @param extraSelector extra selector, use it to save selected result 149 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 150 | */ 151 | selectWhenE(limit: number, value: any, colIndex?: number): Table 152 | /** 153 | * Select the rows when the column's values are equal to specified values. 154 | * @param limit maximum length of selected results (0 is infinite, if you only need 1 result, 1 is recommended, it will improve performance) 155 | * @param value1 first specified value 156 | * @param value2 second specified value 157 | * @param colIndex2 second specified column index 158 | * @param colIndex1 first specified column index 159 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 160 | */ 161 | selectWhenE2(limit: number, value1: any, value2: any, colIndex2?: number, colIndex1?: number): Table 162 | /** 163 | * Select the rows when the column's values are equal to specified values. 164 | * @param limit maximum length of selected results (0 is infinite, if you only need 1 result, 1 is recommended, it will improve performance) 165 | * @param value1 first specified value 166 | * @param value2 second specified value 167 | * @param value3 third specified value 168 | * @param colIndex3 third specified column index 169 | * @param colIndex2 second specified column index 170 | * @param colIndex1 first specified column index 171 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 172 | */ 173 | selectWhenE3(limit: number, value1: any, value2: any, value3: any, colIndex3?: number, colIndex2?: number, colIndex1?: number): Table 174 | /** 175 | * Select the rows when the column's value is greater than specified value. 176 | * @param limit maximum length of selected results (0 is infinite, if you only need 1 result, 1 is recommended, it will improve performance) 177 | * @param withEqu whether include equation 178 | * @param value the specified value 179 | * @param colIndex specified column index 180 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 181 | */ 182 | selectWhenG(limit: number, withEqu: boolean, value: number, colIndex?: number): Table 183 | /** 184 | * Select the rows when the column's value is less than specified values. 185 | * @param limit maximum length of selected results (0 is infinite, if you only need 1 result, 1 is recommended, it will improve performance) 186 | * @param withEqu whether include equation 187 | * @param value the specified value 188 | * @param colIndex specified column index 189 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 190 | */ 191 | selectWhenL(limit: number, withEqu: boolean, value: number, colIndex?: number): Table 192 | /** 193 | * Select the rows when the column's value is greater than specified value and less than specified value. 194 | * @param limit maximum length of selected results (0 is infinite, if you only need 1 result, 1 is recommended, it will improve performance) 195 | * @param GWithEqu whether greater and equal 196 | * @param LWithEqu whether less and equal 197 | * @param GValue the specified greater value 198 | * @param LValue the specified less value 199 | * @param colIndex specified column index 200 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 201 | */ 202 | selectWhenGreaterAndLess(limit: number, GWithEqu: boolean, LWithEqu: boolean, GValue: number, LValue: number, colIndex?: number): Table 203 | /** 204 | * Select the rows when the column's value is less than specified value or greater than specified value. 205 | * @param limit maximum length of selected results (0 is infinite, if you only need 1 result, 1 is recommended, it will improve performance) 206 | * @param LWithEqu whether less and equal 207 | * @param GWithEqu whether greater and equal 208 | * @param LValue the specified less value 209 | * @param GValue the specified greater value 210 | * @param colIndex specified column index 211 | * @return THIS instance (for Method Chaining), can call "to..." or "select..." function in next step. 212 | */ 213 | selectWhenLessOrGreater(limit: number, LWithEqu: boolean, GWithEqu: boolean, LValue: number, GValue: number, colIndex?: number): Table 214 | /** 215 | * Parse csv conent. 216 | * @param content As name mean 217 | * @param filedSeparator filed separator 218 | * @param filedDelimiter filed delimiter 219 | * @return a table instance 220 | */ 221 | static Parse(content: String, filedSeparator?: String, filedDelimiter?: String): Table; 222 | } 223 | } -------------------------------------------------------------------------------- /release/docs/hx/styles.css: -------------------------------------------------------------------------------- 1 | .main-content { 2 | margin-top: 15px; 3 | } 4 | 5 | .dark { 6 | background: rgb(20, 20, 25); 7 | color: white; 8 | } 9 | 10 | .dark a { 11 | color: white; 12 | } 13 | 14 | .dark a:hover { 15 | color: rgb(200, 200, 200); 16 | } 17 | 18 | .dark blockquote { 19 | border-left: 3px solid rgb(126, 126, 129); 20 | } 21 | 22 | .dark blockquote small { 23 | color: white; 24 | font-weight: bold; 25 | } 26 | 27 | .dark blockquote small:before { 28 | display: none; 29 | } 30 | 31 | /* #nav { */ 32 | /* float: left; */ 33 | /* width: 250px; */ 34 | /* background: green; */ 35 | /* } */ 36 | /*#content .header { position:absolute; background:rgba(255,255,255,0.9); left:250px; right:15px; padding:0px 12px; border-bottom:1px solid #EEE;}*/ 37 | /*#content .body { padding-top:80px;}*/ 38 | .nav-list { 39 | padding-right: 0; 40 | } 41 | 42 | .nav-list>li>a, 43 | .nav-list .nav-header { 44 | margin-right: 0; 45 | } 46 | 47 | .nav-list>li>a.treeLink { 48 | padding-left: 20px; 49 | } 50 | 51 | .nav-list a { 52 | overflow: hidden; 53 | text-overflow: ellipsis; 54 | font-size: 14px; 55 | text-shadow: none !important; 56 | } 57 | 58 | .nav-list>.active>a.treeLink, 59 | .nav-list>.active>a.treeLink:hover, 60 | .nav-list>.active>a.treeLink:focus { 61 | background: #999; 62 | color: #fff; 63 | } 64 | 65 | .nav-list li i.fa { 66 | height: 16px; 67 | width: 16px; 68 | color: rgb(200, 200, 200); 69 | font-weight: normal; 70 | font-size: 16px; 71 | } 72 | 73 | .viewsource { 74 | float: right 75 | } 76 | 77 | /** Footer sitemap **/ 78 | footer { 79 | font-size: 14px; 80 | margin-top: auto; 81 | } 82 | 83 | .main-content { 84 | margin-bottom: 40px; 85 | } 86 | 87 | .section.site-footer { 88 | border-bottom: 0px; 89 | } 90 | 91 | .copyright { 92 | padding: 6px; 93 | overflow: hidden; 94 | text-align: center; 95 | margin: 40px 0; 96 | } 97 | 98 | .dark .copyright a { 99 | color: #F48821; 100 | } 101 | 102 | /* .doc { margin-top:16px; } */ 103 | .toggle-hide { 104 | display: block; 105 | } 106 | 107 | .toggle-show { 108 | display: none; 109 | } 110 | 111 | .toggle-on .toggle-hide { 112 | display: none !important; 113 | } 114 | 115 | .toggle-on .toggle-show { 116 | display: block !important; 117 | } 118 | 119 | .related-types .toggle-hide { 120 | padding-top: 4px; 121 | } 122 | 123 | /* .availability { margin-left:14px; color:#93a1a1; } */ 124 | /* .doc { margin-left:14px; } */ 125 | 126 | 127 | 128 | /* #nav li { list-style-type: none; } */ 129 | #nav .expando>ul { 130 | display: none; 131 | } 132 | 133 | #nav .expando.expanded>ul { 134 | display: inherit; 135 | } 136 | 137 | /* #nav ul, #nav li li { margin-left: 10px; } */ 138 | #nav img { 139 | padding-right: 4px; 140 | } 141 | 142 | #nav .pack { 143 | display: none; 144 | } 145 | 146 | /* .nav .nav li { margin-left: 14px; } */ 147 | 148 | .dropdown { 149 | padding: 0 9px; 150 | } 151 | 152 | #nav.searching .expando>ul { 153 | display: inherit; 154 | } 155 | 156 | #nav.searching .expando>a { 157 | display: none; 158 | } 159 | 160 | #nav.searching ul { 161 | margin-left: 0px; 162 | } 163 | 164 | #nav.searching .pack { 165 | display: inline; 166 | } 167 | 168 | #nav.searching .nav-list .nav-list { 169 | padding-left: 0; 170 | padding-right: 0; 171 | } 172 | 173 | .nav-header { 174 | text-transform: none; 175 | font-size: 14px; 176 | color: #555; 177 | text-shadow: none; 178 | } 179 | 180 | .availability { 181 | color: #e48931; 182 | font-size: 90%; 183 | } 184 | 185 | h3 code { 186 | background: none; 187 | box-shadow: 0 0 15px rgb(240, 240, 240); 188 | padding: 4px 8px; 189 | white-space: inherit; 190 | display: inline-block; 191 | line-height: 1.5em; 192 | margin-left: -10px; 193 | } 194 | 195 | h3 span.label, 196 | .label-meta { 197 | margin-right: 5px; 198 | } 199 | 200 | .label.label-meta { 201 | background: #5959AC; 202 | } 203 | 204 | /* hide meta that has doesn't belong in the API (implementation details) */ 205 | .label-meta-impl, 206 | .label-meta-value, 207 | .label-meta-has_untyped, 208 | .label-meta-hlNative, 209 | .label-meta-access, 210 | .label-meta-allow, 211 | .label-meta-keep, 212 | .label-meta-keepInit, 213 | .label-meta-keepSub, 214 | .label-meta-dox, 215 | .label-meta-noCompletion, 216 | .label-meta-directlyUsed, 217 | .label-meta-build, 218 | .label-meta-autoBuild, 219 | .label-meta-genericBuild, 220 | .label-meta-analyzer, 221 | .label-meta-enum, 222 | .label-meta-extern { 223 | display: none; 224 | } 225 | 226 | .label-meta.label-meta-from, 227 | .label-meta.label-meta-to { 228 | background: #a93685; 229 | } 230 | 231 | .alert.alert-deprecated { 232 | font-size: 90%; 233 | margin-bottom: 10px; 234 | padding: 4px 35px 4px 14px; 235 | } 236 | 237 | code { 238 | font-family: Monaco, Menlo, Consolas, "Courier New", monospace; 239 | font-weight: normal; 240 | color: #666; 241 | background-color: #f7f7f9; 242 | border: 1px solid #e1e1e8; 243 | white-space: nowrap; 244 | border-radius: 3px; 245 | padding: 2px 4px; 246 | font-size: 13px; 247 | } 248 | 249 | code .identifier { 250 | font-family: bold 14px "Helvetica Neue", Helvetica, Arial, sans-serif; 251 | color: #002b36; 252 | padding: 0 0 0 5px; 253 | } 254 | 255 | code .identifier, 256 | code.type { 257 | font-weight: bold; 258 | } 259 | 260 | /* code { background:#FDF6E3; color:#002b36; tab-size:4; } [> light <] */ 261 | code a { 262 | text-decoration: none; 263 | } 264 | 265 | code a:hover { 266 | text-decoration: underline; 267 | } 268 | 269 | /*code.dark { background:#272822; color:#F8F8F2; border:none; } */ 270 | code .type { 271 | color: #268bd2; 272 | } 273 | 274 | /* code .keyword { color:#dc322f; } */ 275 | /* code .directive { color:#2aa198; } */ 276 | /* code .constant { color:#AE81FF; } */ 277 | /* code .comment { color:#75715E; } */ 278 | /* code .string { color:#E6DB74; } */ 279 | /* code .macro { color:#A6E22A; } */ 280 | /* code .inactive { color:#75715E; } */ 281 | 282 | /* .navbar-fixed-top { position: fixed; } */ 283 | /* .navbar-fixed-top .navbar-inner, */ 284 | /* .navbar-fixed-bottom .navbar-inner { padding: 0; } */ 285 | 286 | html, 287 | body { 288 | height: 100%; 289 | margin: 0; 290 | } 291 | 292 | body { 293 | margin: 0px; 294 | padding: 0px; 295 | font-size: 16px; 296 | font-family: "Open Sans", sans-serif; 297 | color: #1e1e1e; 298 | line-height: 1.5; 299 | display: flex; 300 | flex-direction: column; 301 | } 302 | 303 | h1, 304 | h2, 305 | h3, 306 | h4, 307 | h5, 308 | h6 { 309 | font-family: "Source Sans Pro", sans-serif; 310 | font-weight: 600; 311 | word-wrap: break-word; 312 | } 313 | 314 | h1 { 315 | font-size: 36px; 316 | color: #171717; 317 | } 318 | 319 | h1 small { 320 | font-size: 14px; 321 | color: #999; 322 | font-weight: normal; 323 | } 324 | 325 | h2 { 326 | font-size: 30px; 327 | } 328 | 329 | h3 { 330 | font-size: 24px; 331 | } 332 | 333 | h4 { 334 | font-size: 20px; 335 | } 336 | 337 | h5, 338 | h5 code { 339 | font-size: 18px; 340 | } 341 | 342 | h6 { 343 | font-size: 16px; 344 | } 345 | 346 | .sidebar-nav { 347 | padding: 9px 0; 348 | } 349 | 350 | #searchForm { 351 | padding: 0 9px; 352 | margin-bottom: 10px; 353 | } 354 | 355 | #searchForm .control-group { 356 | margin: 0; 357 | } 358 | 359 | .indent { 360 | margin-left: 20px; 361 | border-left: 5px solid #eeeeee; 362 | padding-left: 20px; 363 | } 364 | 365 | table.params { 366 | border-left: 5px solid #eeeeee; 367 | margin-left: 20px; 368 | } 369 | 370 | table.params th { 371 | background: #fcfcfc; 372 | } 373 | 374 | .doc-main { 375 | margin-bottom: 40px; 376 | } 377 | 378 | .doc-main p { 379 | font-style: italic; 380 | } 381 | 382 | .section { 383 | border-bottom: 1px solid #eee; 384 | } 385 | 386 | .table p { 387 | margin: 3px 0; 388 | } 389 | 390 | .table th, 391 | .table td { 392 | border-top: 0; 393 | border-bottom: 1px solid #ccc; 394 | } 395 | 396 | .table a small { 397 | color: #666; 398 | } 399 | 400 | .table .fa { 401 | color: rgb(200, 200, 200); 402 | margin-right: 5px; 403 | } 404 | 405 | .javadoc { 406 | /* font-weight: normal; */ 407 | /* font-size: small; */ 408 | margin-top: 20px; 409 | font-style: italic; 410 | } 411 | 412 | .inline-content * { 413 | display: inline; 414 | } 415 | 416 | /** 417 | * Stuff for input-block-level: 418 | * http://stackoverflow.com/questions/13306670/bootstrap-prepended-and-appended-input-how-to-max-input-field-width 419 | */ 420 | .input-append.input-block-level, 421 | .input-prepend.input-block-level { 422 | display: table; 423 | } 424 | 425 | .input-append.input-block-level .add-on, 426 | .input-prepend.input-block-level .add-on { 427 | display: table-cell; 428 | } 429 | 430 | .input-append.input-block-level>input, 431 | .input-prepend.input-block-level>input { 432 | box-sizing: border-box; 433 | /* use bootstrap mixin or include vendor variants */ 434 | -moz-box-sizing: border-box; 435 | /* for Firefox */ 436 | -webkit-box-sizing: border-box; 437 | /* for Firefox */ 438 | -ms-box-sizing: border-box; 439 | /* for Firefox */ 440 | -o-box-sizing: border-box; 441 | /* for Firefox */ 442 | display: table; 443 | /* table-cell is not working well in Chrome for small widths */ 444 | min-height: inherit; 445 | width: 100%; 446 | } 447 | 448 | .input-append.input-block-level>input { 449 | border-right: 0; 450 | } 451 | 452 | .input-prepend.input-block-level>input { 453 | border-left: 0; 454 | } 455 | 456 | .field { 457 | padding-bottom: 10px; 458 | } 459 | 460 | .field+.field { 461 | border-top: 1px solid #eee; 462 | margin-top: 10px; 463 | } 464 | 465 | .fields { 466 | margin-left: 40px; 467 | } 468 | 469 | .field-source { 470 | margin-top: 15px; 471 | visibility: hidden; 472 | } 473 | 474 | .field:hover .field-source { 475 | visibility: inherit; 476 | } 477 | 478 | pre.example { 479 | position: relative; 480 | padding-top: 34.5px; 481 | } 482 | 483 | pre.example:before { 484 | position: absolute; 485 | top: -1px; 486 | left: -1px; 487 | 488 | content: "Example"; 489 | color: #999; 490 | padding: 2px 6px; 491 | background: #fff; 492 | font-weight: bold; 493 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 494 | 495 | -moz-border-radius: 4px 0; 496 | -ms-border-radius: 4px 0; 497 | -webkit-border-radius: 4px 0; 498 | border-radius: 4px 0; 499 | border: 1px solid rgba(0, 0, 0, 0.15); 500 | } 501 | 502 | .inherited-fields { 503 | padding: 5px 20px; 504 | margin-top: 1em; 505 | background: #fcfcfc; 506 | } 507 | 508 | @media (max-width: 767px) { 509 | 510 | .navbar-fixed-top, 511 | .navbar-fixed-bottom, 512 | .navbar-static-top { 513 | margin-right: 0; 514 | margin-left: 0; 515 | } 516 | 517 | .navbar .divider { 518 | display: none; 519 | } 520 | 521 | .main-content { 522 | margin-top: 0px; 523 | } 524 | } 525 | 526 | @media (max-width: 979px) { 527 | .main-content { 528 | margin-top: 15px; 529 | } 530 | } -------------------------------------------------------------------------------- /release/docs/hx/String.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | String - ACsv library

    The basic String class.

    10 |

    A Haxe String is immutable, it is not possible to modify individual 11 | characters. No method of this class changes the state of this String.

    12 |

    Strings can be constructed using the String literal syntax "string value".

    13 |

    String can be concatenated by using the + operator. If an operand is not a 14 | String, it is passed through Std.string() first.

    See:

    Constructor

    new(string:String)

    Creates a copy from a given String.

    Variables

    read onlylength:Int

    The number of characters in this String.

    Methods

    charAt(index:Int):String

    Returns the character at position index of this String.

    15 |

    If index is negative or exceeds this.length, the empty String "" 16 | is returned.

    @:has_untypedinlinecharCodeAt(index:Int):Null<Int>

    Returns the character code at position index of this String.

    17 |

    If index is negative or exceeds this.length, null is returned.

    18 |

    To obtain the character code of a single character, "x".code can be 19 | used instead to inline the character code at compile time. Note that 20 | this only works on String literals of length 1.

    indexOf(str:String, ?startIndex:Int):Int

    Returns the position of the leftmost occurrence of str within this 21 | String.

    22 |

    If startIndex is given, the search is performed within the substring 23 | of this String starting from startIndex. Otherwise the search is 24 | performed within this String. In either case, the returned position 25 | is relative to the beginning of this String.

    26 |

    If str cannot be found, -1 is returned.

    lastIndexOf(str:String, ?startIndex:Int):Int

    Returns the position of the rightmost occurrence of str within this 27 | String.

    28 |

    If startIndex is given, the search is performed within the substring 29 | of this String from 0 to startIndex. Otherwise the search is 30 | performed within this String. In either case, the returned position 31 | is relative to the beginning of this String.

    32 |

    If str cannot be found, -1 is returned.

    split(delimiter:String):Array<String>

    Splits this String at each occurrence of delimiter.

    33 |

    If this String is the empty String "", the result is not consistent 34 | across targets and may either be [] (on Js, Cpp) or [""].

    35 |

    If delimiter is the empty String "", this String is split into an 36 | Array of this.length elements, where the elements correspond to the 37 | characters of this String.

    38 |

    If delimiter is not found within this String, the result is an Array 39 | with one element, which equals this String.

    40 |

    If delimiter is null, the result is unspecified.

    41 |

    Otherwise, this String is split into parts at each occurrence of 42 | delimiter. If this String starts (or ends) with delimiter, the 43 | result Array contains a leading (or trailing) empty String "" element. 44 | Two subsequent delimiters also result in an empty String "" element.

    @:has_untypedinlinesubstr(pos:Int, ?len:Int):String

    Returns len characters of this String, starting at position pos.

    45 |

    If len is omitted, all characters from position pos to the end of 46 | this String are included.

    47 |

    If pos is negative, its value is calculated from the end of this 48 | String by this.length + pos. If this yields a negative value, 0 is 49 | used instead.

    50 |

    If the calculated position + len exceeds this.length, the characters 51 | from that position to the end of this String are returned.

    52 |

    If len is negative, the result is unspecified.

    substring(startIndex:Int, ?endIndex:Int):String

    Returns the part of this String from startIndex to but not including endIndex.

    53 |

    If startIndex or endIndex are negative, 0 is used instead.

    54 |

    If startIndex exceeds endIndex, they are swapped.

    55 |

    If the (possibly swapped) endIndex is omitted or exceeds 56 | this.length, this.length is used instead.

    57 |

    If the (possibly swapped) startIndex exceeds this.length, the empty 58 | String "" is returned.

    toLowerCase():String

    Returns a String where all characters of this String are lower case.

    59 |

    Affects the characters A-Z. Other characters remain unchanged.

    toString():String

    Returns the String itself.

    toUpperCase():String

    Returns a String where all characters of this String are upper case.

    60 |

    Affects the characters a-z. Other characters remain unchanged.

    Static methods

    staticfromCharCode(code:Int):String

    Returns the String corresponding to the character code code.

    61 |

    If code is negative or has another invalid value, the result is 62 | unspecified.

    -------------------------------------------------------------------------------- /src/java/org/json/JSONStringer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.json; 18 | 19 | import java.util.ArrayList; 20 | import java.util.Arrays; 21 | import java.util.List; 22 | 23 | // Note: this class was written without inspecting the non-free org.json sourcecode. 24 | 25 | /** 26 | * Implements {@link JSONObject#toString} and {@link JSONArray#toString}. Most 27 | * application developers should use those methods directly and disregard this 28 | * API. For example:
     29 |  * JSONObject object = ...
     30 |  * String json = object.toString();
    31 | * 32 | *

    Stringers only encode well-formed JSON strings. In particular: 33 | *

      34 | *
    • The stringer must have exactly one top-level array or object. 35 | *
    • Lexical scopes must be balanced: every call to {@link #array} must 36 | * have a matching call to {@link #endArray} and every call to {@link 37 | * #object} must have a matching call to {@link #endObject}. 38 | *
    • Arrays may not contain keys (property names). 39 | *
    • Objects must alternate keys (property names) and values. 40 | *
    • Values are inserted with either literal {@link #value(Object) value} 41 | * calls, or by nesting arrays or objects. 42 | *
    43 | * Calls that would result in a malformed JSON string will fail with a 44 | * {@link JSONException}. 45 | * 46 | *

    This class provides no facility for pretty-printing (ie. indenting) 47 | * output. To encode indented output, use {@link JSONObject#toString(int)} or 48 | * {@link JSONArray#toString(int)}. 49 | * 50 | *

    Some implementations of the API support at most 20 levels of nesting. 51 | * Attempts to create more than 20 levels of nesting may fail with a {@link 52 | * JSONException}. 53 | * 54 | *

    Each stringer may be used to encode a single top level value. Instances of 55 | * this class are not thread safe. Although this class is nonfinal, it was not 56 | * designed for inheritance and should not be subclassed. In particular, 57 | * self-use by overrideable methods is not specified. See Effective Java 58 | * Item 17, "Design and Document or inheritance or else prohibit it" for further 59 | * information. 60 | */ 61 | public class JSONStringer { 62 | 63 | /** The output data, containing at most one top-level array or object. */ 64 | final StringBuilder out = new StringBuilder(); 65 | 66 | /** 67 | * Lexical scoping elements within this stringer, necessary to insert the 68 | * appropriate separator characters (ie. commas and colons) and to detect 69 | * nesting errors. 70 | */ 71 | enum Scope { 72 | 73 | /** 74 | * An array with no elements requires no separators or newlines before 75 | * it is closed. 76 | */ 77 | EMPTY_ARRAY, 78 | 79 | /** 80 | * A array with at least one value requires a comma and newline before 81 | * the next element. 82 | */ 83 | NONEMPTY_ARRAY, 84 | 85 | /** 86 | * An object with no keys or values requires no separators or newlines 87 | * before it is closed. 88 | */ 89 | EMPTY_OBJECT, 90 | 91 | /** 92 | * An object whose most recent element is a key. The next element must 93 | * be a value. 94 | */ 95 | DANGLING_KEY, 96 | 97 | /** 98 | * An object with at least one name/value pair requires a comma and 99 | * newline before the next element. 100 | */ 101 | NONEMPTY_OBJECT, 102 | 103 | /** 104 | * A special bracketless array needed by JSONStringer.join() and 105 | * JSONObject.quote() only. Not used for JSON encoding. 106 | */ 107 | NULL, 108 | } 109 | 110 | /** 111 | * Unlike the original implementation, this stack isn't limited to 20 112 | * levels of nesting. 113 | */ 114 | private final List stack = new ArrayList(); 115 | 116 | /** 117 | * A string containing a full set of spaces for a single level of 118 | * indentation, or null for no pretty printing. 119 | */ 120 | private final String indent; 121 | 122 | public JSONStringer() { 123 | indent = null; 124 | } 125 | 126 | JSONStringer(int indentSpaces) { 127 | char[] indentChars = new char[indentSpaces]; 128 | Arrays.fill(indentChars, ' '); 129 | indent = new String(indentChars); 130 | } 131 | 132 | /** 133 | * Begins encoding a new array. Each call to this method must be paired with 134 | * a call to {@link #endArray}. 135 | * 136 | * @return this stringer. 137 | */ 138 | public JSONStringer array() throws JSONException { 139 | return open(Scope.EMPTY_ARRAY, "["); 140 | } 141 | 142 | /** 143 | * Ends encoding the current array. 144 | * 145 | * @return this stringer. 146 | */ 147 | public JSONStringer endArray() throws JSONException { 148 | return close(Scope.EMPTY_ARRAY, Scope.NONEMPTY_ARRAY, "]"); 149 | } 150 | 151 | /** 152 | * Begins encoding a new object. Each call to this method must be paired 153 | * with a call to {@link #endObject}. 154 | * 155 | * @return this stringer. 156 | */ 157 | public JSONStringer object() throws JSONException { 158 | return open(Scope.EMPTY_OBJECT, "{"); 159 | } 160 | 161 | /** 162 | * Ends encoding the current object. 163 | * 164 | * @return this stringer. 165 | */ 166 | public JSONStringer endObject() throws JSONException { 167 | return close(Scope.EMPTY_OBJECT, Scope.NONEMPTY_OBJECT, "}"); 168 | } 169 | 170 | /** 171 | * Enters a new scope by appending any necessary whitespace and the given 172 | * bracket. 173 | */ 174 | JSONStringer open(Scope empty, String openBracket) throws JSONException { 175 | if (stack.isEmpty() && out.length() > 0) { 176 | throw new JSONException("Nesting problem: multiple top-level roots"); 177 | } 178 | beforeValue(); 179 | stack.add(empty); 180 | out.append(openBracket); 181 | return this; 182 | } 183 | 184 | /** 185 | * Closes the current scope by appending any necessary whitespace and the 186 | * given bracket. 187 | */ 188 | JSONStringer close(Scope empty, Scope nonempty, String closeBracket) throws JSONException { 189 | Scope context = peek(); 190 | if (context != nonempty && context != empty) { 191 | throw new JSONException("Nesting problem"); 192 | } 193 | 194 | stack.remove(stack.size() - 1); 195 | if (context == nonempty) { 196 | newline(); 197 | } 198 | out.append(closeBracket); 199 | return this; 200 | } 201 | 202 | /** 203 | * Returns the value on the top of the stack. 204 | */ 205 | private Scope peek() throws JSONException { 206 | if (stack.isEmpty()) { 207 | throw new JSONException("Nesting problem"); 208 | } 209 | return stack.get(stack.size() - 1); 210 | } 211 | 212 | /** 213 | * Replace the value on the top of the stack with the given value. 214 | */ 215 | private void replaceTop(Scope topOfStack) { 216 | stack.set(stack.size() - 1, topOfStack); 217 | } 218 | 219 | /** 220 | * Encodes {@code value}. 221 | * 222 | * @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, 223 | * Integer, Long, Double or null. May not be {@link Double#isNaN() NaNs} 224 | * or {@link Double#isInfinite() infinities}. 225 | * @return this stringer. 226 | */ 227 | public JSONStringer value(Object value) throws JSONException { 228 | if (stack.isEmpty()) { 229 | throw new JSONException("Nesting problem"); 230 | } 231 | 232 | if (value instanceof JSONArray) { 233 | ((JSONArray) value).writeTo(this); 234 | return this; 235 | 236 | } else if (value instanceof JSONObject) { 237 | ((JSONObject) value).writeTo(this); 238 | return this; 239 | } 240 | 241 | beforeValue(); 242 | 243 | if (value == null 244 | || value instanceof Boolean 245 | || value == JSONObject.NULL) { 246 | out.append(value); 247 | 248 | } else if (value instanceof Number) { 249 | out.append(JSONObject.numberToString((Number) value)); 250 | 251 | } else { 252 | string(value.toString()); 253 | } 254 | 255 | return this; 256 | } 257 | 258 | /** 259 | * Encodes {@code value} to this stringer. 260 | * 261 | * @return this stringer. 262 | */ 263 | public JSONStringer value(boolean value) throws JSONException { 264 | if (stack.isEmpty()) { 265 | throw new JSONException("Nesting problem"); 266 | } 267 | beforeValue(); 268 | out.append(value); 269 | return this; 270 | } 271 | 272 | /** 273 | * Encodes {@code value} to this stringer. 274 | * 275 | * @param value a finite value. May not be {@link Double#isNaN() NaNs} or 276 | * {@link Double#isInfinite() infinities}. 277 | * @return this stringer. 278 | */ 279 | public JSONStringer value(double value) throws JSONException { 280 | if (stack.isEmpty()) { 281 | throw new JSONException("Nesting problem"); 282 | } 283 | beforeValue(); 284 | out.append(JSONObject.numberToString(value)); 285 | return this; 286 | } 287 | 288 | /** 289 | * Encodes {@code value} to this stringer. 290 | * 291 | * @return this stringer. 292 | */ 293 | public JSONStringer value(long value) throws JSONException { 294 | if (stack.isEmpty()) { 295 | throw new JSONException("Nesting problem"); 296 | } 297 | beforeValue(); 298 | out.append(value); 299 | return this; 300 | } 301 | 302 | private void string(String value) { 303 | out.append("\""); 304 | for (int i = 0, length = value.length(); i < length; i++) { 305 | char c = value.charAt(i); 306 | 307 | /* 308 | * From RFC 4627, "All Unicode characters may be placed within the 309 | * quotation marks except for the characters that must be escaped: 310 | * quotation mark, reverse solidus, and the control characters 311 | * (U+0000 through U+001F)." 312 | */ 313 | switch (c) { 314 | case '"': 315 | case '\\': 316 | case '/': 317 | out.append('\\').append(c); 318 | break; 319 | 320 | case '\t': 321 | out.append("\\t"); 322 | break; 323 | 324 | case '\b': 325 | out.append("\\b"); 326 | break; 327 | 328 | case '\n': 329 | out.append("\\n"); 330 | break; 331 | 332 | case '\r': 333 | out.append("\\r"); 334 | break; 335 | 336 | case '\f': 337 | out.append("\\f"); 338 | break; 339 | 340 | default: 341 | if (c <= 0x1F) { 342 | out.append(String.format("\\u%04x", (int) c)); 343 | } else { 344 | out.append(c); 345 | } 346 | break; 347 | } 348 | 349 | } 350 | out.append("\""); 351 | } 352 | 353 | private void newline() { 354 | if (indent == null) { 355 | return; 356 | } 357 | 358 | out.append("\n"); 359 | for (int i = 0; i < stack.size(); i++) { 360 | out.append(indent); 361 | } 362 | } 363 | 364 | /** 365 | * Encodes the key (property name) to this stringer. 366 | * 367 | * @param name the name of the forthcoming value. May not be null. 368 | * @return this stringer. 369 | */ 370 | public JSONStringer key(String name) throws JSONException { 371 | if (name == null) { 372 | throw new JSONException("Names must be non-null"); 373 | } 374 | beforeKey(); 375 | string(name); 376 | return this; 377 | } 378 | 379 | /** 380 | * Inserts any necessary separators and whitespace before a name. Also 381 | * adjusts the stack to expect the key's value. 382 | */ 383 | private void beforeKey() throws JSONException { 384 | Scope context = peek(); 385 | if (context == Scope.NONEMPTY_OBJECT) { // first in object 386 | out.append(','); 387 | } else if (context != Scope.EMPTY_OBJECT) { // not in an object! 388 | throw new JSONException("Nesting problem"); 389 | } 390 | newline(); 391 | replaceTop(Scope.DANGLING_KEY); 392 | } 393 | 394 | /** 395 | * Inserts any necessary separators and whitespace before a literal value, 396 | * inline array, or inline object. Also adjusts the stack to expect either a 397 | * closing bracket or another element. 398 | */ 399 | private void beforeValue() throws JSONException { 400 | if (stack.isEmpty()) { 401 | return; 402 | } 403 | 404 | Scope context = peek(); 405 | if (context == Scope.EMPTY_ARRAY) { // first in array 406 | replaceTop(Scope.NONEMPTY_ARRAY); 407 | newline(); 408 | } else if (context == Scope.NONEMPTY_ARRAY) { // another in array 409 | out.append(','); 410 | newline(); 411 | } else if (context == Scope.DANGLING_KEY) { // value for key 412 | out.append(indent == null ? ":" : ": "); 413 | replaceTop(Scope.NONEMPTY_OBJECT); 414 | } else if (context != Scope.NULL) { 415 | throw new JSONException("Nesting problem"); 416 | } 417 | } 418 | 419 | /** 420 | * Returns the encoded JSON string. 421 | * 422 | *

    If invoked with unterminated arrays or unclosed objects, this method's 423 | * return value is undefined. 424 | * 425 | *

    Warning: although it contradicts the general contract 426 | * of {@link Object#toString}, this method returns null if the stringer 427 | * contains no data. 428 | */ 429 | @Override public String toString() { 430 | return out.length() == 0 ? null : out.toString(); 431 | } 432 | } 433 | --------------------------------------------------------------------------------