Lib/tjson.h File Reference

Tiny JSON ライブラリヘッダ. More...

#include "tools.h"
#include "ttree.h"
#include "jbxl_state.h"
Include dependency graph for tjson.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define JSON_ANCHOR_NODE   JBXL_STATE_ANCHOR
 アンカーノード
#define JSON_TEMP_NODE   -1
 一時的なノード.削除対象.
#define JSON_BRACKET_NODE   1
 '{' を格納したノード.key は持たない.
#define JSON_DATA_NODE   2
 通常のノード
#define JSON_ARRAY_NODE   3
 配列ノード.処理された場合,JSON_ARRAY_VALUE_NODE を子ノードとして持つ.
#define JSON_ARRAY_VALUE_NODE   4
 配列の要素データのノード.
#define JSON_VALUE_UNRESOLV   -1
 属性値の種類は未確定.
#define JSON_VALUE_NULL   0
 属性値なし.
#define JSON_VALUE_INT   1
 属性値:整数 未サポート
#define JSON_VALUE_REAL   2
 属性値:実数 未サポート
#define JSON_VALUE_BOOL   3
 属性値:論理値 未サポート
#define JSON_VALUE_STR   4
 属性値:文字列
#define JSON_VALUE_OBJ   5
 属性値:オブジェクト
#define JSON_VALUE_ARRAY   6
 属性値:配列
#define JSON_ONELINE_FORMAT   0
 改行なしの一行にする.
#define JSON_CRLF_FORMAT   1
 ノードの終わりを CR(0x0d), LF(0x0a)で改行する.
#define JSON_INDENT_FORMAT   2
 先頭にインデント(TAB)をつけ,ノードごとに改行する.
#define new_json_node()   new_tTree_node()
 JSONデータのノードを生成 new_tTree_node().
#define new_json_anchor_node()   new_tTree_anchor_node()
 JSONデータの ANCHORノードを生成 new_tTree_anchor_node().
#define new_json()   new_tTree_node()
 JSONデータのノードを生成 new_tTree_node().
#define new_json_anchor()   new_tTree_anchor_node()
 JSONデータの ANCHORノードを生成 new_tTree_anchor_node().
#define new_json_anchor_node()   new_tTree_anchor_node()
 JSONデータの ANCHORノードを生成 new_tTree_anchor_node().
#define del_json_anchor(t)   del_tTree_anchor_node((t))
 JSONデータの ANCHORノードを削除 del_tTree_anchor_node().
#define del_json_anchor_node(t)   del_tTree_anchor_node((t))
 JSONデータの ANCHORノードを削除 del_tTree_anchor_node().
#define del_json(j)   del_tTree((j))
 JSONデータの削除 del_tTree().
#define del_json_node(j)   del_tTree_node((j))
 JSONデータのノード削除 del_tTree_node().
#define free_json(j)   free_tTree_node((j))
 JSONデータのノードデータを解放 free_tTree_node().
#define free_json_node(j)   free_tTree_node((j))
 JSONデータのノードデータを解放 free_tTree_node().
#define print_tJson(f, j)   print_tTree((f), (j))
#define print_tJson_tree(f, j, s)   print_tTree_tree((f), (j), (s))
#define dup_merge_json(p, c)   dup_merge_tTree((p), (c))
 p の子として c の複製を繋げる.
#define find_top_json(p, n)   search_top_bracket_json((p), (n))
 search_top_bracket_json()
#define find_sister_json(p, n)   search_sister_json((p), (n))
 search_sister_json()
#define find_key_json(p, k)   search_key_json((p), (k), FALSE, 1)
 search_key_json()
#define find_key_child_json(p, k)   search_key_child_json( (p), (k), FALSE)
 search_key_child_json()
#define find_key_sister_json(p, k)   search_key_sister_json((p), (k), FALSE)
 search_key_sister_json()
#define find_key_json_obj(p, k)   search_key_json_obj((p), (k))
 search_key_json_obj()
#define find_double_key_json(p, k1, k2)   search_double_key_json((p), (k1), (k2), FALSE)
 search_doublekey_json()

Typedefs

typedef tTree tJson

Functions

tJsonjson_parse (char *pp, int num)
 文字列のJSONデータを解釈して,tJsonのツリーを生成する.
tJsonjson_parse_prop (tJson *json, char *pp, int num)
 JSON Main Parser.
tJsonjson_parse_seq (tJson *json, char *pp, int num)
 断片化した JSONデータを読み込んで処理する.
tJsonjson_array_parse (tJson *json, char *pp, int num)
 JSONデータの 配列ノードの値(配列データ)を処理する..
tJson_json_array_parse (tJson *json, int num)
 json_parse_prop() の補助関数.配列処理用.
tJson_json_parse_term (tJson *json, char *st, char *ed, const char *com)
 json_parse_prop() の補助関数.断片的な入力データ用.
Buffer json_inverse_parse (tJson *pp, int mode)
 tJsonデータをmodeに従って元の書式に戻して Bufferに格納する.
Buffer json_inverse_parse_opt (tJson *pp, const char *crlf, const char *space)
 tJsonデータを指定に従って元の書式に戻して Bufferに格納する.
void print_json (FILE *fp, tJson *json, int mode)
 tJsonデータをmodeに従って fp に出力する.
void print_json_opt (FILE *fp, tJson *json, const char *crlf, const char *space)
 tJsonデータを指定に従って fp に出力する.
void _json_to_Buffer (tJson *pp, Buffer *buf, const char *crlf, const char *space)
 tJsonデータを元の書式に戻して Bufferに格納する.補助関数.
tJsonjson_parse_file (const char *fn, int num)
 JSONデータをファイルから読み込んで,パースする..
void json_set_str_val (tJson *json, char *str)
 json ノードに文字列の属性値を設定する.
void json_copy_val (tJson *f_json, tJson *t_json)
 f_json から t_json へ属性値をコピーする.
void json_copy_data (tJson *f_json, tJson *t_json)
 f_json から t_json へ属性名と属性値をコピーする.
void insert_json_nodes (tJson *parent, tJson *child)
tJsonjoin_json (tJson *parenr, tJson **child)
 parent の子として child そのものを繋げる.
tJsonsearch_top_bracket_json (tJson *pp, int nn)
 ツリーが複数のルート(TOP)を持つ場合(JBXL_JSON_MULTI_ROOT),指定されたTOPへのポインタを返す.
tJsonsearch_sister_json (tJson *pp, int nn)
 nn個先の sister ノードを返す.正数の場合は younger sister. 負数の場合は elder sister.
tJsonsearch_key_json (tJson *pp, char *key, int needval, int nn)
 名前(属性名)が key である nn番目のノードへのポインタを返す
tJsonsearch_key_child_json (tJson *pp, char *key, int needval)
 子の姉妹ノードで名前(属性名)が key である nn番目のノードへのポインタを返す.
tJsonsearch_key_sister_json (tJson *pp, char *key, int needval)
 姉妹ノードで名前(属性名)が key である nn番目のノードへのポインタを返す.
tJsonsearch_key_json_obj (tJson *pp, char *key, int nn)
 名前(属性名)が key である nn番目のオブジェクトノードへのポインタを返す. ex.) "hoge": {
tJsonsearch_double_key_json (tJson *pp, char *key1, char *key2, int needval)
 属性名が key1 -> key2 の親子関係を持つ,key2ノードのポインタを返す.
tJson_search_key_json (tJson *pp, char *key, int need, int *nn)
 search_key_json() の補助関数
tJson_search_key_json_obj (tJson *pp, char *key, int *nn)
 search_key_json_obj() の補助関数
int _json_check_node_bykey (tJson *pp, char *key, int needval, int nn)
 search 系関数の補助関数
Buffer get_json_val (tJson *json)
Buffer get_key_json_val (tJson *pp, char *key, int nn)
 名前(属性名)が key である nn番目のノードの属性値を返す.
Buffer get_key_sister_json_val (tJson *pp, char *key)
 姉妹ノードで名前(属性名)が key である nn番目のノードの属性値を返す.
Buffer get_double_key_json_val (tJson *pp, char *key1, char *key2)
 key1 -> key2 の親子関係を持つ,key2ノードの属性値を返す.
Buffer get_Buffer_from_json (tJson *json)
char * get_string_from_json (tJson *json)
 要 free()
tListsearch_all_node_strval_json (tJson *json, char *name, char *val)
 指定した条件に合う全てのノードへのポインタを,リストに格納して返す.
tList_search_all_node_strval_json (tList *list, tJson *pp, char *name, char *val)
 search_all_node_strval_json() の補助関数

Detailed Description

Version:
1.2.0
Author:
Fumi.Iseki (C)
Date:
2021 8/19
タイトル
Tiny JSON tjson.h v1.0
サブセット版 JSON 簡易Parser ライブラリヘッダ
See also:
tJson
Attention:
全てのパターンのパース可能性は保障しない.

Definition in file tjson.h.


Define Documentation

#define del_json (  )     del_tTree((j))

Definition at line 65 of file tjson.h.

#define del_json_anchor (  )     del_tTree_anchor_node((t))

Definition at line 62 of file tjson.h.

#define del_json_anchor_node (  )     del_tTree_anchor_node((t))

Definition at line 63 of file tjson.h.

#define del_json_node (  )     del_tTree_node((j))

Definition at line 66 of file tjson.h.

Referenced by join_json(), json_array_parse(), and json_parse_prop().

#define dup_merge_json ( p,
 )     dup_merge_tTree((p), (c))

Definition at line 199 of file tjson.h.

#define find_double_key_json ( p,
k1,
k2   )     search_double_key_json((p), (k1), (k2), FALSE)

Definition at line 211 of file tjson.h.

#define find_key_child_json ( p,
 )     search_key_child_json( (p), (k), FALSE)

Definition at line 208 of file tjson.h.

#define find_key_json ( p,
 )     search_key_json((p), (k), FALSE, 1)

Definition at line 207 of file tjson.h.

#define find_key_json_obj ( p,
 )     search_key_json_obj((p), (k))

Definition at line 210 of file tjson.h.

#define find_key_sister_json ( p,
 )     search_key_sister_json((p), (k), FALSE)

Definition at line 209 of file tjson.h.

#define find_sister_json ( p,
 )     search_sister_json((p), (n))

Definition at line 206 of file tjson.h.

#define find_top_json ( p,
 )     search_top_bracket_json((p), (n))

Definition at line 205 of file tjson.h.

#define free_json (  )     free_tTree_node((j))

Definition at line 67 of file tjson.h.

#define free_json_node (  )     free_tTree_node((j))

Definition at line 68 of file tjson.h.

#define JSON_ANCHOR_NODE   JBXL_STATE_ANCHOR
#define JSON_ARRAY_NODE   3
#define JSON_ARRAY_VALUE_NODE   4

Definition at line 35 of file tjson.h.

Referenced by _json_to_Buffer(), and json_array_parse().

#define JSON_BRACKET_NODE   1
#define JSON_CRLF_FORMAT   1

Definition at line 50 of file tjson.h.

Referenced by json_inverse_parse().

#define JSON_DATA_NODE   2

Definition at line 33 of file tjson.h.

Referenced by _json_to_Buffer(), _search_all_node_strval_json(), and json_parse_prop().

#define JSON_INDENT_FORMAT   2

Definition at line 51 of file tjson.h.

Referenced by json_inverse_parse().

#define JSON_ONELINE_FORMAT   0

Definition at line 49 of file tjson.h.

#define JSON_TEMP_NODE   -1

Definition at line 31 of file tjson.h.

Referenced by join_json(), json_array_parse(), and json_parse_prop().

#define JSON_VALUE_ARRAY   6

Definition at line 46 of file tjson.h.

Referenced by get_Buffer_from_json(), get_string_from_json(), and json_parse_prop().

#define JSON_VALUE_BOOL   3

Definition at line 43 of file tjson.h.

Referenced by json_parse_prop().

#define JSON_VALUE_INT   1

Definition at line 41 of file tjson.h.

#define JSON_VALUE_NULL   0

Definition at line 40 of file tjson.h.

Referenced by _json_to_Buffer(), json_array_parse(), and json_parse_prop().

#define JSON_VALUE_OBJ   5
#define JSON_VALUE_REAL   2

Definition at line 42 of file tjson.h.

#define JSON_VALUE_STR   4
#define JSON_VALUE_UNRESOLV   -1

Definition at line 39 of file tjson.h.

Referenced by json_array_parse(), and json_parse_prop().

 
#define new_json (  )     new_tTree_node()

Definition at line 59 of file tjson.h.

 
#define new_json_anchor (  )     new_tTree_anchor_node()

Definition at line 60 of file tjson.h.

 
#define new_json_anchor_node (  )     new_tTree_anchor_node()

Definition at line 61 of file tjson.h.

 
#define new_json_anchor_node (  )     new_tTree_anchor_node()

Definition at line 61 of file tjson.h.

Referenced by json_parse().

 
#define new_json_node (  )     new_tTree_node()

Definition at line 57 of file tjson.h.

Referenced by json_array_parse(), json_parse_prop(), and search_all_node_strval_json().

#define print_tJson ( f,
 )     print_tTree((f), (j))

Definition at line 184 of file tjson.h.

#define print_tJson_tree ( f,
j,
 )     print_tTree_tree((f), (j), (s))

Definition at line 185 of file tjson.h.


Typedef Documentation

typedef tTree tJson;

tJson (tList, tTree, _tList と同じもの)

See also:
tTree

1. ノードデータ tJson:

    int     ldat.id     オブジェクトの種別. JSON_ANCHOR_NODE, JSON_BRACKET_NODE, JSON_DATA_NODE, JSON_ARRAY_NODE
    int     ldat.lv     属性値の形式. JSON_VALUE_NULL, JSON_VALUE_UNRESOLV, JSON_VALUE_INT, JSON_VALUE_STR など
    int     ldat.sz     配列処理の回数.
    Buffer  ldat.key    属性の名前
    Buffer  ldat.val    属性の値
    void*   ldat.ptr    未使用 
    tJson*  ldat.lst    未使用

    tJson*  next        子ノード(長女)へのポインタ
    tJson*  prev        親ノードへのポインタ
    tJson*  altp        汎用
    tJson*  yngr        子ノード(末っ子)へのポインタ    

    tJson*  esis        前の姉妹(姉)ノードへのポインタ
    tJson*  ysis        次の姉妹(妹)ノードへのポインタ

    int     depth       深さ                    
    int     num         子ノードの数(全ての子ノードの数)    
    int     ctrl        制御用
    int     state       ノードの状態  JBXL_JSON_DEFAULT_STATE, JBXL_JSON_PARSED, JBXL_JSON_PARSE_TERM, JBXL_JSON_MULTI_ROOT, ....

2. パースしたJSON情報を格納するツリー構造

    {"A":{"B":{"C":ABC, "DEFG"}, "E":"X"}} 
    
    (JSON_ANCHOR_NODE)
        -> { (JSON_BRACKET_NODE)
            -> "A":{ (JSON_DATA_NODE, JSON_VALUE_OBJ)
                -> "B":{ (JSON_DATA_NODE, JSON_VALUE_OBJ) 
                    -> "C":ABC (JSON_DATA_NODE, JSON_VALUE_UNRESOLV)
                    -> "DEFG" (JSON_DATA_NODE, JSON_VALUE_NULL)
                -> "E":"X" (JSON_DATA_NODE, JSON_VALUE_STR)

3, ノード(ノード)種別 (ldat.id)

    JSON_ANCHOR_NODE            アンカーノード
    JSON_TEMP_NODE              一時的なノード.削除対象.
    JSON_BRACKET_NODE           '{' を格納したノード.key は持たない. 
    JSON_DATA_NODE              通常のノード
    JSON_ARRAY_NODE             配列ノード.処理された場合,JSON_ARRAY_VALUE_NODE を子ノードとして持つ.
    JSON_ARRAY_VALUE_NODE       配列の要素データのノード.

4. 属性値の形式(ldat.lv)

    JSON_VALUE_UNRESOLV
    JSON_VALUE_NULL  
    JSON_VALUE_INT  
    JSON_VALUE_REAL 
    JSON_VALUE_BOOL
    JSON_VALUE_STR
    JSON_VALUE_OBJ  
    JSON_VALUE_ARRAY 

5. 状態 (state)

    JBXL_JSON_DEFAULT_STATE     ノードは,正常にパースされたかどうかの判定はまだ行われていない.
    JBXL_JSON_PARSED            アンカーノードにのみ設定される.このJSONツリーは正常にパースされたことを示す.
    JBXL_JSON_MULTI_ROOT        アンカーノードにのみ設定される.このJSONツリーは 2つ以上の独立したツリーを持つ
    JBXL_JSON_NODE_OPENED       このノードはオープン状態にある. {
    JBXL_JSON_NODE_CLOSED       このノードは正常にクローズした. }
    JBXL_JSON_NODE_EMPTY        JSONの空のノード
    JBXL_JSON_NOT_CLOSED        最終的にノードが閉じなかったが,解釈できるところまでは解釈した.
    JBXL_JSON_PARSE_TERM        JSON のパースが途中で終了した.入力データが不完全.
    JBXL_JSON_IN_STR            SONデータの属性値処理で文字列を処理中.
    JBXL_JSON_IN_ARRAY          JSONデータの属性値処理で配列を処理中.

    JBXL_JSON_ERROR             tJson ライブラリのエラー
    JBXL_JSON_PARSE_ERROR       解釈エラー
    JBXL_JSON_SEQUENCE_ERROR    アンカーを越えてツリーを作ろうとした.
    JBXL_JSON_MEMORY_ERROR      メモリの確保エラー
See also:
jbxl_state.h

Definition at line 157 of file tjson.h.


Function Documentation

tJson* _json_array_parse ( tJson json,
int  num 
)

tJson* _json_array_parse(tJson* json, int num)

JSONデータの 配列ノードの値(配列データ)を処理する.

Parameters:
json 処理を行う JSON ノードデータ.
num 処理の残り段数.
Returns:
処理された JSON ノードデータ.

Definition at line 353 of file tjson.c.

References free_Buffer(), and json_array_parse().

Referenced by json_parse_prop().

00354 {
00355     char* pp = (char*)(json->ldat.val.buf);
00356     //
00357     json = json_array_parse(json, pp, num);
00358     free_Buffer(&(json->ldat.val));
00359 
00360     return json;
00361 }

Here is the call graph for this function:

Here is the caller graph for this function:

int _json_check_node_bykey ( tJson pp,
char *  key,
int  needval,
int  nn 
)

int _json_check_node_bykey(tJson* pp, char* key, int needval, int nn)

pp が指すノードの名前(属性名)が key である場合,nnを 1減算して返す. needval が TRUE の場合は,値(属性値)を持っている場合のみ減算する.

Definition at line 1238 of file tjson.c.

Referenced by _search_key_json(), _search_key_json_obj(), search_key_json(), search_key_json_obj(), and search_key_sister_json().

01239 {
01240     if (pp->ldat.key.buf!=NULL) {
01241         if (!strcmp(key, (char*)pp->ldat.key.buf)) {
01242             if (needval) {
01243                 unsigned char* pm = pp->ldat.val.buf;
01244                 if (pm!=NULL) { 
01245                     if (!((pm[0]=='\'' && pm[1]=='\'') || (pm[0]=='"' && pm[1]=='"')) && pm[0]!='\0') nn--; 
01246                 }
01247             }
01248             else {
01249                 nn--;
01250             }
01251         }
01252     }
01253     return nn;
01254 }

Here is the caller graph for this function:

tJson* _json_parse_term ( tJson json,
char *  st,
char *  ed,
const char *  com 
)

tJson* _json_parse_term(tJson* json, char* st, char* ed, const char* com)

入力データが途中で終了した場合の処理

Definition at line 484 of file tjson.c.

References cat_b2Buffer(), JBXL_JSON_PARSE_TERM, and set_Buffer().

Referenced by json_parse_prop().

00485 {
00486     if (json==NULL) return NULL;
00487 
00488     json->state = JBXL_JSON_PARSE_TERM;
00489     if (com!=NULL) {
00490         json->ldat.val = set_Buffer((void*)com, -1);
00491         if (st!=NULL && ed!=NULL) {
00492             int len = (int)(ed - st) + 1;
00493             cat_b2Buffer(st, &(json->ldat.val), len);
00494             json->ldat.val.vldsz = (int)strlen((char*)json->ldat.val.buf);
00495         }
00496     }    
00497     return json;
00498 }

Here is the call graph for this function:

Here is the caller graph for this function:

void _json_to_Buffer ( tJson pp,
Buffer buf,
const char *  crlf,
const char *  space 
)

void _json_to_Buffer(tJson* pp, Buffer* buf, const char* crlf, const char* space)

json_inverse_parse()用の補助関数. ppに格納された JSONデータを元の書式に戻して Bufferに格納する.

Parameters:
pp JSONデータが格納されたツリーへのポインタ
buf 変換したJSONデータを格納する Buffer変数.データ格納領域は予め確保しておく.
crlf JSONへ戻す時の改行コード
space インデントを付ける場合の空白やTAB

Definition at line 625 of file tjson.c.

References _json_to_Buffer(), Buffer::buf, cat_Buffer(), cat_s2Buffer, JSON_ANCHOR_NODE, JSON_ARRAY_NODE, JSON_ARRAY_VALUE_NODE, JSON_BRACKET_NODE, JSON_DATA_NODE, JSON_VALUE_NULL, JSON_VALUE_OBJ, and TREE_NOSIS_NODE.

Referenced by _json_to_Buffer(), json_inverse_parse(), and json_inverse_parse_opt().

00626 {
00627     if (pp==NULL) return;
00628     if (buf==NULL || buf->buf==NULL) return;
00629     //
00630     if (pp->ldat.id==JSON_ANCHOR_NODE) pp = pp->next;
00631 
00632     if (pp!=NULL) {
00633         if (pp->ctrl!=TREE_NOSIS_NODE) while(pp->esis!=NULL) pp = pp->esis; // 長女から逆パースを開始.
00634         do {
00635             int i;
00636             if (space[0]!='\0') for(i=0; i<pp->depth; i++) cat_s2Buffer(space, buf);
00637             //
00638             if (pp->ldat.id==JSON_BRACKET_NODE) {
00639                 cat_s2Buffer("{", buf);
00640                 if (pp->next!=NULL) {
00641                     if (crlf[0]!='\0') cat_s2Buffer(crlf, buf);
00642                     _json_to_Buffer(pp->next, buf, crlf, space);
00643                     if (space[0]!='\0') for(i=0; i<pp->depth; i++) cat_s2Buffer(space, buf);
00644                 }
00645                 //if (space[0]!='\0') for(i=0; i<pp->depth; i++) cat_s2Buffer(space, buf);
00646                 cat_s2Buffer("}", buf); 
00647             }
00648             //
00649             else if (pp->ldat.id==JSON_DATA_NODE) {
00650                 cat_s2Buffer("\"", buf);
00651                 cat_s2Buffer(pp->ldat.key.buf, buf);
00652                 cat_s2Buffer("\"", buf);
00653                 //
00654                 if (pp->ldat.lv==JSON_VALUE_OBJ) {
00655                     cat_s2Buffer(": {", buf);
00656                     if (pp->next!=NULL) {
00657                         if (crlf[0]!='\0') cat_s2Buffer(crlf, buf);
00658                         _json_to_Buffer(pp->next, buf, crlf, space);
00659                         if (space[0]!='\0') for(i=0; i<pp->depth; i++) cat_s2Buffer(space, buf);
00660                     }
00661                     //if (space[0]!='\0') for(i=0; i<pp->depth; i++) cat_s2Buffer(space, buf);
00662                     cat_s2Buffer("}", buf); 
00663                 }
00664                 else {
00665                     if (pp->ldat.lv==JSON_VALUE_NULL) {
00666                         cat_s2Buffer(": null", buf);
00667                     }
00668                     else  {
00669                         cat_s2Buffer(": ", buf);
00670                         cat_s2Buffer(pp->ldat.val.buf, buf);
00671                     }
00672                 }
00673             }
00674             //
00675             // array
00676             else if (pp->ldat.id==JSON_ARRAY_NODE) {
00677                 cat_s2Buffer("\"", buf);
00678                 cat_s2Buffer(pp->ldat.key.buf, buf);
00679                 cat_s2Buffer("\": [", buf);
00680                 if (pp->next!=NULL) {
00681                     if (crlf[0]!='\0') cat_s2Buffer(crlf, buf);
00682                     _json_to_Buffer(pp->next, buf, crlf, space);
00683                     if (space[0]!='\0') for(i=0; i<pp->depth; i++) cat_s2Buffer(space, buf);
00684                 }
00685                 //if (space[0]!='\0') for(i=0; i<pp->depth; i++) cat_s2Buffer(space, buf);
00686                 cat_s2Buffer("]", buf); 
00687             }
00688 
00689             else if (pp->ldat.id==JSON_ARRAY_VALUE_NODE) {
00690                 if (pp->ldat.lv==JSON_VALUE_OBJ) {
00691                     if (pp->ldat.val.buf==NULL) {
00692                         cat_s2Buffer("{", buf);
00693                         if (pp->next!=NULL) {
00694                             if (crlf[0]!='\0') cat_s2Buffer(crlf, buf);
00695                             _json_to_Buffer(pp->next, buf, crlf, space);
00696                             if (space[0]!='\0') for(i=0; i<pp->depth; i++) cat_s2Buffer(space, buf);
00697                         }
00698                         //if (space[0]!='\0') for(i=0; i<pp->depth; i++) cat_s2Buffer(space, buf);
00699                         cat_s2Buffer("}", buf); 
00700                     }
00701                     else {
00702                         cat_Buffer(&pp->ldat.val, buf);
00703                     }
00704                 }
00705                 else {
00706                     if (pp->ldat.lv==JSON_VALUE_NULL) {
00707                         cat_s2Buffer("null", buf);
00708                     }
00709                     else  {
00710                         cat_s2Buffer(pp->ldat.val.buf, buf);
00711                     }
00712                 }
00713             }
00714 
00715             if (pp->ctrl!=TREE_NOSIS_NODE && pp->ysis!=NULL && 
00716                 pp->prev!=NULL && pp->prev->ldat.id!=JSON_ANCHOR_NODE) cat_s2Buffer(",", buf);
00717             if (crlf[0]!='\0') cat_s2Buffer(crlf, buf);
00718 
00719             if (pp->ctrl!=TREE_NOSIS_NODE) pp = pp->ysis;
00720             else                           pp = NULL;
00721         } while(pp!=NULL);
00722     }
00723 
00724     return;
00725 }

Here is the call graph for this function:

Here is the caller graph for this function:

tList* _search_all_node_strval_json ( tList list,
tJson pp,
char *  name,
char *  val 
)

Definition at line 1282 of file tjson.c.

References _search_all_node_strval_json(), add_tList_node, JSON_ARRAY_NODE, JSON_BRACKET_NODE, JSON_DATA_NODE, JSON_VALUE_OBJ, JSON_VALUE_STR, and new_tList_node().

Referenced by _search_all_node_strval_json(), and search_all_node_strval_json().

01283 {
01284     while (pp->esis!=NULL) pp = pp->esis;
01285     do {
01286         if (pp->ldat.id==JSON_DATA_NODE) {
01287             if (!strncasecmp(name, (char*)pp->ldat.key.buf, strlen(name))) {
01288                 if (pp->ldat.lv==JSON_VALUE_STR) {
01289                     if (!strncasecmp(val, (char*)(pp->ldat.val.buf+1), strlen(val))) {
01290                         list->altp = pp;
01291                         tList* temp = new_tList_node();
01292                         temp->ldat.id = list->ldat.id + 1;
01293                         add_tList_node(list, temp);
01294                         list = temp;
01295                     }
01296                 }
01297             }
01298             else if (pp->ldat.id==JSON_VALUE_OBJ) {
01299                 if (pp->next!=NULL) {
01300                     list = _search_all_node_strval_json(list, pp->next, name, val);
01301                 }
01302             }
01303         }
01304         else if (pp->ldat.id==JSON_BRACKET_NODE || pp->ldat.id==JSON_ARRAY_NODE) {
01305             if (pp->next!=NULL) {
01306                 list = _search_all_node_strval_json(list, pp->next, name, val);
01307             }
01308         }
01309         pp = pp->ysis;
01310     } while (pp!=NULL);
01311 
01312     return list;
01313 }

Here is the call graph for this function:

Here is the caller graph for this function:

tJson* _search_key_json ( tJson pp,
char *  key,
int  need,
int *  nn 
)

Definition at line 1163 of file tjson.c.

References _json_check_node_bykey(), and _search_key_json().

Referenced by _search_key_json(), and search_key_json().

01164 {
01165     while(pp->esis!=NULL) pp = pp->esis;
01166     tJson* esis = pp;
01167 
01168     while(pp!=NULL) {
01169         *nn = _json_check_node_bykey(pp, key, needval, *nn);
01170         if ((*nn)<=0) return pp;
01171         pp = pp->ysis;
01172     }
01173 
01174     // 子ノード
01175     pp = esis;
01176     while(pp!=NULL) {
01177         if (pp->next!=NULL) {
01178             tJson* json = _search_key_json(pp->next, key, needval, nn);
01179             if (json!=NULL) return json;
01180         }
01181         pp = pp->ysis;
01182     }
01183     
01184     return NULL; 
01185 }

Here is the call graph for this function:

Here is the caller graph for this function:

tJson* _search_key_json_obj ( tJson pp,
char *  key,
int *  nn 
)

Definition at line 1203 of file tjson.c.

References _json_check_node_bykey(), _search_key_json_obj(), FALSE, and JSON_VALUE_OBJ.

Referenced by _search_key_json_obj(), and search_key_json_obj().

01204 {
01205     if (pp==NULL) return NULL;
01206     while(pp->esis!=NULL) pp = pp->esis;
01207     tJson* esis = pp;
01208 
01209     while(pp!=NULL) {
01210         if (pp->ldat.lv==JSON_VALUE_OBJ) {
01211             *nn = _json_check_node_bykey(pp, key, FALSE, *nn);
01212         }
01213         if ((*nn)<=0) return pp;
01214         pp = pp->ysis;
01215     }
01216 
01217     // 子ノード
01218     pp = esis;
01219     while(pp!=NULL) {
01220         if (pp->next!=NULL) {
01221             tJson* json = _search_key_json_obj(pp->next, key, nn);
01222             if (json!=NULL) return json;
01223         }
01224         pp = pp->ysis;
01225     }
01226     
01227     return NULL; 
01228 }

Here is the call graph for this function:

Here is the caller graph for this function:

Buffer get_Buffer_from_json ( tJson json  ) 

Buffer get_Buffer_from_json(tJson* json)

JSON データのノード値の文字列をを含む Buffer変数を返す. "" または '' で囲まれている場合は,その内部のデータ("", ''の中味)の返す.

Definition at line 1410 of file tjson.c.

References init_Buffer(), JSON_VALUE_ARRAY, and make_Buffer_str.

01411 {
01412     Buffer buf = init_Buffer();
01413 
01414     if (json==NULL) return buf;
01415 
01416     char* pp = (char*)json->ldat.val.buf;
01417 
01418     if (pp!=NULL && json->ldat.lv!=JSON_VALUE_ARRAY) {
01419         if (*pp=='\"' || *pp=='\'') {
01420             char* pt = (char*)&(json->ldat.val.buf[json->ldat.val.vldsz-1]);
01421             if (*pp==*pt) {
01422                 pp++;
01423                 char bkup = *pt;
01424                 *pt = '\0';
01425                 buf = make_Buffer_str(pp);
01426                 *pt = bkup;
01427             }
01428         }
01429         else {
01430             buf = make_Buffer_str(pp);
01431         }
01432     }
01433 
01434     return buf;
01435 }

Here is the call graph for this function:

Buffer get_double_key_json_val ( tJson pp,
char *  key1,
char *  key2 
)

Buffer get_double_key_json_val(tJson* pp, char* key1, char* key2)

key1 -> key2 の親子関係を持つ,key2ノードの属性値を返す. 属性値が文字列の場合,先頭と最後の または ' は削除する.

Parameters:
pp 探索を開始するノード.
key1 探索するノード名.
key2 探索するノード名.
Returns:
見つかったノードの属性値を格納した Buffer 変数.

Definition at line 1393 of file tjson.c.

References get_json_val(), search_double_key_json(), and TRUE.

01394 {
01395     tJson* json = search_double_key_json(pp, key1, key2, TRUE);
01396     Buffer val  = get_json_val(json);
01397 
01398     return val;
01399 }

Here is the call graph for this function:

Buffer get_json_val ( tJson json  ) 

Definition at line 1318 of file tjson.c.

References Buffer::buf, init_Buffer(), set_Buffer(), and Buffer::vldsz.

Referenced by get_double_key_json_val(), get_key_json_val(), and get_key_sister_json_val().

01319 {
01320     Buffer val = init_Buffer();
01321 
01322     if (json!=NULL) {
01323         char* pp = (char*)json->ldat.val.buf;
01324         if ((*pp=='\"') || (*pp=='\'')) {
01325             val = set_Buffer(pp+1, strlen(pp)-1);
01326             val.buf[val.vldsz-1] = '\0';
01327             val.vldsz = (int)strlen((const char*)val.buf);
01328         }
01329         else {
01330             val = set_Buffer(pp, strlen(pp));
01331         }
01332     }
01333     return val;
01334 }

Here is the call graph for this function:

Here is the caller graph for this function:

Buffer get_key_json_val ( tJson pp,
char *  key,
int  nn 
)

Buffer get_key_json_val(tJson* pp, char* key, int nn)

pp が指すノード以下で,名前(属性名)が key である nn番目のノードへの属性値を返す.
属性値が文字列の場合,先頭と最後の または ' は削除する. pp の姉妹ノードは探索しない.

Parameters:
pp 探索を開始するノード.ppがオブジェクト要素(JSON_VALUE_OBJ)なら,次のノードから探索する.
key 探索するノード名.
nn 一致するノード内,何番目を返すか指定する.nn<=0 は nn==1 とみなす.
Returns:
見つかったノードの属性値を格納した Buffer 変数.

Definition at line 1350 of file tjson.c.

References get_json_val(), search_key_json(), and TRUE.

01351 {
01352     tJson* json = search_key_json(pp, key, TRUE, nn);
01353     Buffer val  = get_json_val(json);
01354 
01355     return val;
01356 }

Here is the call graph for this function:

Buffer get_key_sister_json_val ( tJson pp,
char *  key 
)

Buffer get_key_sister_json_val(tJson* pp, char* key)

pp が指すノードの姉妹で,名前(属性名)が key である nn番目のノードの属性値を返す. 探索対象は探索を開始した姉妹ノードのみ. 属性値が文字列の場合,先頭と最後の または ' は削除する.

Parameters:
pp 探索を開始するノード.
key 探索するノード名.
needval ノードが値(属性値)を持っていない場合は無視する."", '' の場合も無視する.
Returns:
見つかったノードの属性値を格納した Buffer 変数.

Definition at line 1372 of file tjson.c.

References get_json_val(), search_key_sister_json(), and TRUE.

01373 {
01374     tJson* json = search_key_sister_json(pp, key, TRUE);
01375     Buffer val  = get_json_val(json);
01376 
01377     return val;
01378 }

Here is the call graph for this function:

char* get_string_from_json ( tJson json  ) 

char* get_string_from_json(tJson* json)

JSON データのノード値の文字列を返す. "" または '' で囲まれている場合は,その内部のデータ("", ''の中味)の返す. 要 free

Definition at line 1446 of file tjson.c.

References dup_str(), and JSON_VALUE_ARRAY.

01447 {
01448     if (json==NULL) return NULL;
01449 
01450     char* str = NULL;
01451     char* pp  = (char*)json->ldat.val.buf;
01452 
01453     if (pp!=NULL) {
01454         if (json->ldat.lv!=JSON_VALUE_ARRAY) {
01455             if (*pp=='\"' || *pp=='\'') {
01456                 char* pt = (char*)&(json->ldat.val.buf[json->ldat.val.vldsz-1]);
01457                 if (*pp==*pt) {
01458                     pp++;
01459                     char bkup = *pt;
01460                     *pt = '\0';
01461                     str = dup_str(pp);
01462                     *pt = bkup;
01463                 }
01464             }
01465         }
01466         if (str==NULL) str = dup_str(pp);
01467     }
01468 
01469 
01470     return str;
01471 }

Here is the call graph for this function:

void insert_json_nodes ( tJson parent,
tJson child 
)

void insert_json_nodes(tJson* parent, tJson* child)

json ツリー parent に json ツリー child のノードを挿入する.

parent が { の場合 child の { は破棄されて,それ以下のノードが parent の子(姉妹)として結合される. child は破壊される. parent が [ の場合 child はそのまま配列の要素として追加される. parent がそれ外の場合 何の処理も行われない.

Definition at line 874 of file tjson.c.

References add_tTree(), free_tList_data(), JSON_ARRAY_NODE, and JSON_BRACKET_NODE.

00875 {
00876     if (parent==NULL) return;
00877     if (child ==NULL) return;
00878     if (parent->ldat.id!=JSON_BRACKET_NODE && parent->ldat.id!=JSON_ARRAY_NODE) return;
00879     if (child->ldat.id !=JSON_BRACKET_NODE) return;
00880     
00881     if (parent->ldat.id==JSON_BRACKET_NODE) {
00882         tJson* cp = child->next;
00883         while (cp!=NULL) {
00884             add_tTree(parent, cp);
00885             cp = cp->ysis;
00886         }
00887         free_tList_data(&child->ldat);
00888         free(child);
00889     }
00890 
00891     if (parent->ldat.id==JSON_ARRAY_NODE) {
00892         add_tTree(parent, child);
00893     }
00894 
00895     return;
00896 }

Here is the call graph for this function:

tJson* join_json ( tJson parent,
tJson **  child 
)

tJson* join_json(tJson* parent, tJson** child)

parent の子として child そのものを結合する. child が ANCHORノードの場合,ANCHORノードは削除され,*child は書き換えられる.

Parameters:
parent 結合対象の JSONノード
[in] child 結合するJSONノード
[out] child child のTOPがANCHORの場合,ANCHORを削除したjsonツリーのTOP.
Returns:
結合結果の JSON Treeの TOP

Definition at line 911 of file tjson.c.

References add_tTree(), del_json_node, JSON_ANCHOR_NODE, and JSON_TEMP_NODE.

00912 {
00913     if (*child==NULL) return parent;
00914     if (parent==NULL) return *child;            // この場合 ANCHOR はそのまま
00915 
00916     if ((*child)->ldat.id==JSON_ANCHOR_NODE || (*child)->ldat.id==JSON_TEMP_NODE) {  // 子として繋げる場合,ANCHOR, TEMP_NODE は削除
00917         tJson* jtmp = (*child)->next;
00918         del_json_node(child);                       // ANCHOR, TEMP_NODE を削除してつめる.
00919         *child = jtmp;
00920     }
00921 
00922     add_tTree(parent, *child); 
00923 
00924     return parent;
00925 }

Here is the call graph for this function:

tJson* json_array_parse ( tJson json,
char *  pp,
int  num 
)

tJson* json_array_parse(tJson* json, char* pp, int num)

JSONデータの 配列ノードの値(配列データ)を処理する.
先頭に姉妹ノードがない場合は json にNULLを指定しても可.

ただし配列なので,先頭は姉妹ノードだらけ.アンカーノードが必要.
その状態で それでもNULLを指定した場合は,この関数外で TOPの JSON_TEMP_NODE を上手く処理すること.

Parameters:
json JSON ノードデータ.NULLでない場合は,このデータの後に結果が付加される.
NULLでも可.
pp 処理を行うデータ.
num 処理の残り段数.
Returns:
処理された JSON ノードデータ.

Definition at line 380 of file tjson.c.

References add_tTree_node(), del_json_node, free_Buffer(), JSON_ARRAY_NODE, JSON_ARRAY_VALUE_NODE, json_parse_prop(), JSON_TEMP_NODE, JSON_VALUE_NULL, JSON_VALUE_OBJ, JSON_VALUE_STR, JSON_VALUE_UNRESOLV, make_Buffer_bystr, new_json_node, pack_Buffer(), set_Buffer(), skip_char_pair(), and skip_chars().

Referenced by _json_array_parse().

00381 {
00382     char* pt;
00383     if (*pp!='[') return json;
00384 
00385     if (json==NULL) {
00386         json = new_json_node();
00387         json->ldat.id = JSON_TEMP_NODE;
00388     }
00389     else {
00390         json->ldat.id = JSON_ARRAY_NODE;
00391     }
00392     json->ldat.lv = JSON_VALUE_NULL;
00393 
00394     //
00395     pp++;
00396     while (*pp!='\0') {
00397         while (*pp==' ') pp++;
00398         if (*pp!='\0') while (*pp=='\\') pp += 2;
00399 
00400         //
00401         if (*pp==']') break;
00402 
00403         //
00404         else if (*pp=='\'' || *pp=='\"') {
00405             char ch = *pp;
00406             pt = pp + 1;
00407             while (*pt!='\0') {
00408                 while (*pt=='\\') pt += 2;
00409                 if (*pt!='\0') {
00410                     if (*pt==ch) break;
00411                     pt++;
00412                 }
00413             }
00414 
00415             if (*pt!='\0') {
00416                 int len = (int)(pt - pp) + 1 ;
00417                 tJson* node = new_json_node();
00418                 Buffer temp    = set_Buffer(pp, len);
00419                 node->ldat.key = make_Buffer_bystr("ARRAY_VALUE");
00420                 node->ldat.val = pack_Buffer(temp, '\0');
00421                 node->ldat.id  = JSON_ARRAY_VALUE_NODE;
00422                 node->ldat.lv  = JSON_VALUE_STR;
00423                 free_Buffer(&temp);
00424                 add_tTree_node(json, node);
00425             
00426                 pp = pt + 1;
00427             }
00428         }
00429 
00430         //
00431         else if (*pp=='{') {
00432             pt = skip_char_pair(pp, '{', '}');
00433 
00434             int len = (int)(pt - pp) + 1 ;
00435             tJson* node = new_json_node();
00436             Buffer temp    = set_Buffer(pp, len);
00437             node->ldat.val = pack_Buffer(temp, '\0');
00438             node->ldat.id  = JSON_ARRAY_VALUE_NODE;
00439             node->ldat.lv  = JSON_VALUE_OBJ;
00440             free_Buffer(&temp);
00441             
00442             if (num>0) {
00443                 node = json_parse_prop(node, (char*)node->ldat.val.buf, num-1);
00444                 add_tTree_node(json, node);
00445                 del_json_node(&node);           // ノードを詰める
00446             }
00447             else {
00448                 add_tTree_node(json, node);
00449             }
00450 
00451             pp = pt + 1;
00452         }
00453 
00454         else if (*pp==',') {
00455             pp++;
00456         }
00457 
00458         else {
00459             pt = skip_chars(pp, ",}]");
00460 
00461             int len = (int)(pt - pp);
00462             tJson* node = new_json_node();
00463             Buffer temp    = set_Buffer(pp, len);
00464             node->ldat.val = pack_Buffer(temp, '\0');
00465             node->ldat.id  = JSON_ARRAY_VALUE_NODE;
00466             node->ldat.lv  = JSON_VALUE_UNRESOLV;
00467             free_Buffer(&temp);
00468             add_tTree_node(json, node);
00469 
00470             pp = pt;
00471         }
00472     }
00473 
00474     return json;
00475 }

Here is the call graph for this function:

Here is the caller graph for this function:

void json_copy_data ( tJson f_json,
tJson t_json 
)

void json_copy_data(tJson* f_json, tJson* t_json)

JSON ノードの f_json から t_json へ属性名と属性値をコピーする.

Definition at line 847 of file tjson.c.

References copy_Buffer().

00848 {
00849     if (f_json==NULL || t_json==NULL) return;
00850 
00851     t_json->ldat.id = f_json->ldat.id;
00852     t_json->ldat.lv = f_json->ldat.lv;
00853     copy_Buffer(&(f_json->ldat.key), &(t_json->ldat.key));
00854     copy_Buffer(&(f_json->ldat.val), &(t_json->ldat.val));
00855 
00856     return;
00857 }

Here is the call graph for this function:

void json_copy_val ( tJson f_json,
tJson t_json 
)

void json_copy_val(tJson* f_json, tJson* t_json)

JSON ノードの f_json から t_json へ属性値をコピーする.

Definition at line 830 of file tjson.c.

References copy_Buffer().

00831 {
00832     if (f_json==NULL || t_json==NULL) return;
00833 
00834     t_json->ldat.lv = f_json->ldat.lv;
00835     copy_Buffer(&(f_json->ldat.val), &(t_json->ldat.val));
00836 
00837     return;
00838 }

Here is the call graph for this function:

Buffer json_inverse_parse ( tJson pp,
int  mode 
)

Buffer json_inverse_parse(tJson* pp, int mode)

ppに格納された tJsonデータを mode に従って,元の書式に戻して Bufferに格納する.json_parse() の逆.

Parameters:
pp tJsonデータが格納されたツリーへのポインタ
mode JSON_ONELINE_FORMAT 改行なしの一行にする.
mode JSON_CRLF_FORMAT ノードの終わりを CR(0x0d), LF(0x0a)で改行する.
mode JSON_INDENT_FORMAT 先頭にインデント(" ")をつけ,ノードごとに改行 CR LF (0x0d,0x0a)する.
Returns:
変換したJSONデータを格納した Buffer変数.

Definition at line 551 of file tjson.c.

References _json_to_Buffer(), Buffer::buf, count_tTree(), init_Buffer(), JSON_ANCHOR_NODE, JSON_CRLF_FORMAT, JSON_INDENT_FORMAT, LSDATA, make_Buffer(), and TREE_NOSIS_NODE.

Referenced by print_json().

00552 {
00553     int cnt;
00554     Buffer buf;
00555 
00556     buf = init_Buffer();
00557     if (pp==NULL) return buf;
00558     if (pp->ldat.id==JSON_ANCHOR_NODE) pp = pp->next;
00559     if (pp==NULL) return buf;
00560 
00561     cnt = count_tTree(pp);
00562     buf = make_Buffer(cnt*LSDATA);
00563     if (buf.buf==NULL) return buf;
00564 
00565     if (pp->ctrl!=TREE_NOSIS_NODE) while (pp->esis!=NULL) pp = pp->esis;
00566 
00567     if (mode==JSON_CRLF_FORMAT) {
00568         _json_to_Buffer(pp, &buf, "\r\n", "");
00569     }
00570     else if (mode==JSON_INDENT_FORMAT) {
00571         _json_to_Buffer(pp, &buf, "\r\n", "    ");
00572     }
00573     else {
00574         _json_to_Buffer(pp, &buf, "", "");
00575     }
00576 
00577     return buf;
00578 }

Here is the call graph for this function:

Here is the caller graph for this function:

Buffer json_inverse_parse_opt ( tJson pp,
const char *  crlf,
const char *  space 
)

Buffer json_inverse_parse_opt(tJson* pp, const char* crlf, const char* space)

ppに格納された tJsonデータを指定にしたっがて元の書式に戻して Bufferに格納する.

Parameters:
pp tJsonデータが格納されたツリーへのポインタ
crlf json へ戻す時の改行コード
space インデントを付ける場合の空白やTAB
Returns:
変換したJSONデータを格納した Buffer変数.

Definition at line 592 of file tjson.c.

References _json_to_Buffer(), Buffer::buf, count_tTree(), init_Buffer(), JSON_ANCHOR_NODE, LSDATA, make_Buffer(), and TREE_NOSIS_NODE.

Referenced by print_json_opt().

00593 {
00594     int cnt;
00595     Buffer buf;
00596 
00597     buf = init_Buffer();
00598     if (pp==NULL) return buf;
00599     if (pp->ldat.id==JSON_ANCHOR_NODE) pp = pp->next;
00600     if (pp==NULL) return buf;
00601 
00602     cnt = count_tTree(pp);
00603     buf = make_Buffer(cnt*LSDATA);
00604     if (buf.buf==NULL) return buf;
00605 
00606     if (pp->ctrl!=TREE_NOSIS_NODE) while (pp->esis!=NULL) pp = pp->esis;
00607     _json_to_Buffer(pp, &buf, crlf, space);
00608 
00609     return buf;
00610 }

Here is the call graph for this function:

Here is the caller graph for this function:

tJson* json_parse ( char *  pp,
int  num 
)

tJson* json_parse(char* pp, int num)

文字列のJSONデータを解釈して,tJsonのツリーを生成する. ツリーのトップは JSON_ANCHOR_NODE となる.

Parameters:
pp 文字列の JSONデータへのポインタ.
num 0 配列を処理しない.高速.
1 配列を処するが,配列の中の JSONデータは処理しない.
2 配列の中の { } を処理する.
N 配列処理 + 再帰処理 の段数.
Returns:
JSONデータを格納した tJsonのアンカーへのポインタ.
エラーの場合,next以下のノードにはエラーを起こす直前までの内容が保存される
Return values:
state,: エラーを起こした場合 stateに JBXL_JSON_PARSED 以外の値(負数)が入る.
    tJson* json = json_parse("{\"A\": \"XYZ\"}");

Definition at line 51 of file tjson.c.

References JBXL_JSON_DEFAULT_STATE, JBXL_JSON_MULTI_ROOT, JBXL_JSON_NOT_CLOSED, JBXL_JSON_PARSE_TERM, JBXL_JSON_PARSED, JSON_BRACKET_NODE, json_parse_prop(), and new_json_anchor_node.

Referenced by json_parse_file().

00052 {
00053     while(*pp!='{' && *pp!='\0') pp++;
00054     if (*pp=='\0') return NULL;
00055 
00056     tJson* json = new_json_anchor_node();                    // アンカー
00057     //json->ldat.id = JSON_ANCHOR_NODE;
00058     //json->ldat.lv = JSON_VALUE_OBJ;
00059     //json->state   = JBXL_STATE_ANCHOR;
00060     //json->depth   = -1;
00061 
00062     // パース
00063     tJson* node = json_parse_prop(json, pp, num);
00064     if (node->state<0) return node;
00065     if (node->state==JBXL_JSON_PARSE_TERM) return node;     // 中途半端な入力
00066 
00067     // 元に戻ったか?
00068     if (json==node) {
00069         json->state = JBXL_JSON_PARSED;
00070     }
00071     else {
00072         json->state = JBXL_JSON_NOT_CLOSED;
00073     }
00074 
00075     // JSON rootの数
00076     if (json->next!=NULL) {
00077         int n = 0;
00078         node = json->next;
00079         while(node!=NULL) {
00080             if (node->ldat.id==JSON_BRACKET_NODE) n++;
00081             node = node->ysis;
00082         }
00083         if (n!=1) json->state = JBXL_JSON_MULTI_ROOT;
00084     }
00085     else json->state = JBXL_JSON_DEFAULT_STATE;
00086 
00087     return json;
00088 }

Here is the call graph for this function:

Here is the caller graph for this function:

tJson* json_parse_file ( const char *  fn,
int  num 
)

tJson* json_parse_file(const char* fn, int num)

ファイルから読み込んでパースする.

Parameters:
fn 読み込むファイル名
num 0 配列を処理しない.高速.
1 配列を処するが,配列の中の JSONデータは処理しない.
2 配列の中の { } を処理する.
N 配列処理 + 再帰処理 の段数.
Returns:
JSONデータを格納した tJsonのアンカーへのポインタ

Definition at line 792 of file tjson.c.

References Buffer::buf, free_Buffer(), json_parse(), and read_Buffer_file().

00793 {
00794     tJson* json = NULL;
00795     Buffer buf;
00796 
00797     buf = read_Buffer_file(fn);
00798     if (buf.buf!=NULL) {
00799         json = json_parse((char*)(buf.buf), num);
00800         free_Buffer(&buf);
00801     }
00802 
00803     return json;
00804 }

Here is the call graph for this function:

tJson* json_parse_prop ( tJson json,
char *  pp,
int  num 
)

tJson* json_parse_prop(tJson* json, char* pp, int num)

JSON Main パーサ.
先頭に姉妹ノードがない場合は json にNULLを指定しても可.
処理に json->ctrl を使用(書き換えられる).

Parameters:
json JSONデータへのポインタ.NULLでない場合は,このデータの後に結果が付加される.
pp パースする文字列.
num 0 配列を処理しない.高速.
1 配列を処するが,配列の中の JSONデータは処理しない.
2 配列の中の { } を処理する.
N 配列処理 + 再帰処理 の段数.
Returns:
JSONデータを格納したポインタ.完全にパースできれば,トップを指している筈.

Definition at line 107 of file tjson.c.

References _json_array_parse(), _json_parse_term(), add_tTree_node(), del_json_node, free_Buffer(), JBXL_JSON_NODE_OPENED, JBXL_JSON_PARSE_TERM, JBXL_JSON_PARSED, JBXL_NONE, JSON_BRACKET_NODE, JSON_DATA_NODE, JSON_TEMP_NODE, JSON_VALUE_ARRAY, JSON_VALUE_BOOL, JSON_VALUE_NULL, JSON_VALUE_OBJ, JSON_VALUE_STR, JSON_VALUE_UNRESOLV, new_json_node, pack_Buffer(), set_Buffer(), skip_char_pair(), and skip_string_end().

Referenced by json_array_parse(), json_parse(), and json_parse_seq().

00108 {
00109     char*  pt   = NULL;
00110     tJson* node = NULL;
00111 
00112     if (json==NULL) {
00113         json = new_json_node();
00114         json->ldat.id = JSON_TEMP_NODE;
00115     }
00116 
00117     while (*pp!='\0') {
00118         // 
00119         if (*pp=='{') {
00120             pp++;
00121             if (json->ctrl!=JBXL_JSON_NODE_OPENED) {
00122                 // open {
00123                 if (json->prev==NULL) {
00124                     node = new_json_node();
00125                     node->ldat.id = JSON_BRACKET_NODE;
00126                     node->ldat.lv = JSON_VALUE_OBJ;
00127                     json = add_tTree_node(json, node);
00128                 }
00129                 else {
00130                     if (json->yngr!=NULL) {
00131                         json = json->yngr;
00132                         json->ldat.lv = JSON_VALUE_OBJ;
00133                     }
00134                 }
00135             }
00136             json->ctrl = JBXL_NONE;
00137 
00138             // 最初の \", \', } を見つける
00139             pt = pp;
00140             while(*pt!='\0') {
00141                 while(*pt=='\\') pt += 2;
00142                 if (*pt!='\0') {
00143                     if (*pt=='\'' || *pt=='\"' || *pt=='}') break;
00144                     pt++;
00145                 }
00146             }
00147             if (*pt=='\0') {
00148                 json = _json_parse_term(json, NULL, NULL, "{");
00149                 json->ctrl = JBXL_JSON_NODE_OPENED;
00150                 return json;
00151             }
00152             //
00153 
00154             pp = pt;
00155             if (*pp!='}') {     // \" or \'
00156                 char ch = '\"';
00157                 if (*pt=='\'') ch = '\''; 
00158                 //
00159                 pt = pp + 1;
00160                 while(*pt!='\0') {
00161                     while(*pt=='\\') pt += 2;
00162                     if (*pt!='\0') {
00163                         if (*pt==ch) break;
00164                         pt++;
00165                     }
00166                 }
00167                 if (*pt=='\0') {
00168                     json = _json_parse_term(json, pp, pt, "{");
00169                     json->ctrl = JBXL_JSON_NODE_OPENED;
00170                     return json;
00171                 }
00172 
00173                 int len = (int)(pt - pp) - 1 ;
00174                 node = new_json_node();
00175                 node->ldat.key = set_Buffer(pp + 1, len);
00176                 node->ldat.id  = JSON_DATA_NODE;
00177                 node->ldat.lv  = JSON_VALUE_NULL;
00178                 add_tTree_node(json, node);
00179 
00180                 pt = pt + 1; 
00181                 while(*pt!=',' && *pt!=':' && *pt!='}' && *pt!='\0') pt++; 
00182                 if (*pt=='\0') {
00183                     json->state = JBXL_JSON_PARSE_TERM;
00184                     return json; 
00185                 }
00186                 pp = pt;
00187             }
00188         }
00189 
00190         //
00191         else if (*pp=='[') {
00192             pt = skip_char_pair(pp, '[', ']');
00193             if (*pt=='\0') {
00194                 json = _json_parse_term(json, pp, pt, "[");
00195                 return json;
00196             }
00197 
00198             int len = (int)(pt - pp) + 1;
00199             Buffer temp = set_Buffer(pp, len);
00200             json->yngr->ldat.val = pack_Buffer(temp, '\0');
00201             json->yngr->ldat.lv  = JSON_VALUE_ARRAY;
00202             free_Buffer(&temp);
00203 
00204             pt++; 
00205             while(*pt!=',' && *pt!='}' && *pt!='\0') pt++; 
00206             if (*pt=='\0') {
00207                 json->state = JBXL_JSON_PARSE_TERM;
00208                 return json;    
00209             }
00210             //
00211             if (num>0) _json_array_parse(json->yngr, num-1);
00212 
00213             pp = pt;
00214         }
00215 
00216         //
00217         else if (*pp==',') {
00218             // 最初の \", \', } を見つける
00219             pt = pp;
00220             while(*pt!='\0') {
00221                 while(*pt=='\\') pt += 2;
00222                 if (*pt!='\0') {
00223                     if (*pt=='\'' || *pt=='\"' || *pt=='}') break;
00224                     pt++;
00225                 }
00226             }
00227             if (*pt=='\0') {
00228                 json = _json_parse_term(json, NULL, NULL, ",");
00229                 return json;
00230             }
00231 
00232             pp = pt;
00233             if (*pp!='}') {     // \" or \'
00234                 char ch = '\"';
00235                 if (*pt=='\'') ch = '\''; 
00236                 //
00237                 pt = pp + 1;
00238                 while(*pt!='\0') {
00239                     while(*pt=='\\') pt += 2;
00240                     if (*pt!='\0') {
00241                         if (*pt==ch) break;
00242                         pt++;
00243                     }
00244                 }
00245                 if (*pt=='\0') {
00246                     json = _json_parse_term(json, pp, pt, ",");
00247                     return json;    
00248                 }
00249 
00250                 int len = (int)(pt - pp) - 1 ;
00251                 node = new_json_node();
00252                 node->ldat.key = set_Buffer(pp + 1, len);
00253                 node->ldat.id  = JSON_DATA_NODE;
00254                 node->ldat.lv  = JSON_VALUE_NULL;
00255                 add_tTree_node(json, node);
00256 
00257                 pt = pt + 1; 
00258                 while(*pt!=',' && *pt!=':' && *pt!='}' && *pt!='\0') pt++; 
00259                 if (*pt=='\0') {
00260                     json->state = JBXL_JSON_PARSE_TERM;
00261                     return json;    
00262                 }
00263                 pp = pt;
00264             }
00265         }
00266 
00267         //
00268         else if (*pp==':') {
00269             pt = pp + 1;
00270             while (*pt==' ' && *pt!='\0') pt++;
00271             if (*pt=='\0') {
00272                 json = _json_parse_term(json, NULL, NULL, ":");
00273                 return json;
00274             }
00275             pp = pt;
00276 
00277             if (*pp!='{' && *pp!='[') {
00278                 while(*pt==' ') pt++;
00279                 if (*pt!='\0') while (*pt=='\\') pt += 2;
00280                 //
00281                 if (*pp=='\'' || *pp=='\"') {
00282                     pt = skip_string_end(pt);
00283                     if (*pt!='\0') pt++;
00284                 }
00285                 while (*pt!=',' && *pt!='}' && *pt!='\0') pt++;
00286 
00287                 if (*pt=='\0') {
00288                     json = _json_parse_term(json, pp, pt, ":");
00289                     return json;    
00290                 }
00291                 pt--;
00292                 while (*pt==' ' || *pt==0x0a || *pt==0x0d) pt--;
00293 
00294                 int len = (int)(pt - pp) + 1 ;
00295                 Buffer temp = set_Buffer(pp, len);
00296                 json->yngr->ldat.val = pack_Buffer(temp, '\0');
00297                 free_Buffer(&temp);
00298                 //
00299                 if (*pp=='\"' || *pp=='\'') json->yngr->ldat.lv = JSON_VALUE_STR;
00300                 else {
00301                     const char* val = (const char*)json->yngr->ldat.val.buf;
00302                     if (!strcasecmp("true", val) || !strcasecmp("false", val)) json->yngr->ldat.lv = JSON_VALUE_BOOL;
00303                     else  json->yngr->ldat.lv = JSON_VALUE_UNRESOLV;
00304                 }
00305 
00306                 pt++;
00307                 while (*pt==' ') pt++;
00308                 pp = pt;
00309             }
00310         }
00311 
00312         //
00313         else if (*pp=='}') {
00314             if (json->prev!=NULL) {
00315                 json = json->prev;
00316             }
00317             pt = pp = pp + 1;
00318             while (*pt!=',' && *pt!='}' && *pt!='{' && *pt!='\0') pt++;
00319             if (*pt=='\0' && json->depth>0) {
00320                 json->state = JBXL_JSON_PARSE_TERM;
00321                 return json;    
00322             }
00323             pp = pt;
00324         }
00325 
00326         //
00327         else {
00328             pp++;
00329         }
00330     }
00331 
00332     if (json->ldat.id==JSON_TEMP_NODE) {
00333         tJson* temp = json->next;
00334         del_json_node(&json);
00335         json = temp;
00336     }
00337 
00338     json->state = JBXL_JSON_PARSED;
00339     return json;
00340 }

Here is the call graph for this function:

Here is the caller graph for this function:

tJson* json_parse_seq ( tJson json,
char *  pp,
int  num 
)

tJson* json_parse_seq(tJson* json, char* pp, int num)

断片化した JSONデータを読み込んで処理する.
処理途中の戻り値は色々な場所を指すが,最期までパースできれば,戻り値はトップに戻る.

    tJson* json;
    json = json_parse_seq(NULL, pp1, 99);
    json = json_parse_seq(next, pp2, 99);
    json = json_parse_seq(next, pp3, 99);

Definition at line 515 of file tjson.c.

References Buffer::buf, cat_s2Buffer, dup_Buffer(), free_Buffer(), JBXL_JSON_DEFAULT_STATE, and json_parse_prop().

00516 {
00517     if (json==NULL) {
00518         json = json_parse_prop(NULL, pp, num);
00519         return json;
00520     }
00521 
00522     Buffer buf = dup_Buffer(json->ldat.val);
00523     free_Buffer(&(json->ldat.val));
00524     cat_s2Buffer(pp, &buf);
00525 
00526     json->state = JBXL_JSON_DEFAULT_STATE;
00527     json = json_parse_prop(json, (char*)buf.buf, num);
00528     free_Buffer(&buf);
00529 
00530     return json;
00531 }

Here is the call graph for this function:

void json_set_str_val ( tJson json,
char *  str 
)

void json_set_str_val(tJson* json, char* str)

json ノードに文字列の属性値を設定する.

Definition at line 813 of file tjson.c.

References copy_s2Buffer, and JSON_VALUE_STR.

00814 {
00815     if (json==NULL || str==NULL) return;
00816 
00817     copy_s2Buffer(str, &(json->ldat.val));
00818     json->ldat.lv = JSON_VALUE_STR;
00819 
00820     return;
00821 }

void print_json ( FILE *  fp,
tJson json,
int  mode 
)

void print_json(FILE* fp, tJson* json, int mode)

tJsonデータを modeに従って,fp に出力する.

Parameters:
fp 出力先のファイルポインタ
json tJsonデータが格納されたツリーへのポインタ
mode JSON_ONELINE_FORMAT 改行なしの一行にする.
mode JSON_CRLF_FORMAT ノードの終わりを CR LF(0x0d, 0x0a) で改行する.
mode JSON_INDENT_FORMAT 先頭にインデント(TAB 0x09)をつけ,ノードごとに改行 CR LF (0x0d, 0x0a)する.

Definition at line 740 of file tjson.c.

References Buffer::buf, free_Buffer(), and json_inverse_parse().

00741 {
00742     Buffer buf = json_inverse_parse(json, mode);
00743     if (buf.buf!=NULL) {
00744         fprintf(fp, "%s", buf.buf);
00745         free_Buffer(&buf);
00746     }
00747 
00748     return;
00749 }

Here is the call graph for this function:

void print_json_opt ( FILE *  fp,
tJson json,
const char *  crlf,
const char *  space 
)

void print_json_opt(FILE* fp, tJson* json, const char* crlf, const char* space)

tJsonデータを fp に出力する.

Parameters:
fp 出力先のファイルポインタ
json tJsonデータが格納されたツリーへのポインタ
crlf json へ戻す時の改行コード
space インデントを付ける場合の空白やTAB

Definition at line 763 of file tjson.c.

References Buffer::buf, free_Buffer(), and json_inverse_parse_opt().

00764 {
00765     Buffer buf = json_inverse_parse_opt(json, crlf, space);
00766     if (buf.buf!=NULL) {
00767         fprintf(fp, "%s", buf.buf);
00768         free_Buffer(&buf);
00769     }
00770 
00771     return;
00772 }

Here is the call graph for this function:

tList* search_all_node_strval_json ( tJson pp,
char *  name,
char *  val 
)

tList* search_all_node_strval_json(tJson* pp, char* name, char* val)

指定した条件に会う全てのノードへのポインタを,リストに格納して返す.
検索条件は,属性名 name, 属性値 val ("name": "val") を持つノード.

Parameters:
pp 検索する JSONデータ.
name 属性名
val 属性値
Returns:
検索結果を ldat.altp に格納した リスト.

Definition at line 1269 of file tjson.c.

References _search_all_node_strval_json(), JSON_ANCHOR_NODE, and new_json_node.

01270 {
01271     if (pp!=NULL && pp->ldat.id==JSON_ANCHOR_NODE) pp = pp->next;
01272     if (pp==NULL) return NULL;
01273 
01274     tList* list = new_json_node();
01275     _search_all_node_strval_json(list, pp, name, val);
01276 
01277     return list;
01278 }

Here is the call graph for this function:

tJson* search_double_key_json ( tJson pp,
char *  key1,
char *  key2,
int  needval 
)

tJson* search_double_key_json(tJson* pp, char* key1, char* key2, int needval)

key1 -> key2 の親子関係を持つ,key2ノードのポインタを返す.

Parameters:
pp 探索を開始するノード.
key1 探索するノード名.
key2 探索するノード名.
needval TRUEの時,ky2 ノードが値(属性値)を持っていない場合は無視する."", '' の場合も無視する.
Returns:
見つかったノードへのポインタ.見つからない場合は,NULL

Definition at line 1132 of file tjson.c.

References search_key_json(), and search_key_json_obj().

Referenced by get_double_key_json_val().

01133 {
01134     if (pp==NULL || key1==NULL || key2==NULL) return NULL;
01135 
01136     pp = search_key_json_obj(pp, key1, 1);
01137     if (pp==NULL) return NULL;
01138 
01139     if (pp->next!=NULL) {
01140         pp = search_key_json(pp, key2, needval, 1);
01141     }
01142     else return NULL;
01143 
01144     return pp; 
01145 }

Here is the call graph for this function:

Here is the caller graph for this function:

tJson* search_key_child_json ( tJson pp,
char *  key,
int  needval 
)

tJson* search_key_child_json(tJson* pp, char* key, int needval)

pp が指すノードの子(の姉妹)で,名前(属性名)が key であるノードへのポインタを返す. 探索対象は探索を開始した子の姉妹ノードのみ. needval が TRUE の場合は,値(属性値)を持っている場合のみカウントする.

Parameters:
pp 探索を開始するノード.
key 探索するノード名.
needval TRUE の場合,ノードが値(属性値)を持っていない場合は無視する."", '' の場合も無視する.
Returns:
見つかったノードへのポインタ.見つからない場合は NULL

Definition at line 1047 of file tjson.c.

References JSON_ANCHOR_NODE, and search_key_sister_json().

01048 {
01049     if (pp!=NULL && pp->ldat.id==JSON_ANCHOR_NODE) pp = pp->next;
01050     if (pp==NULL || pp->next==NULL) return NULL;
01051 
01052     tJson* json = search_key_sister_json(pp->next, key, needval);
01053 
01054     return json;
01055 }

Here is the call graph for this function:

tJson* search_key_json ( tJson pp,
char *  key,
int  needval,
int  nn 
)

tJson* search_key_json(tJson* pp, char* key, int needval, int nn)

pp が指すノード以下で,名前(属性名)が key である nn番目のノードへのポインタを返す.
needval が TRUE の場合は,値(属性値)を持っている場合のみカウントする. pp の姉妹ノードは探索しない.

Parameters:
pp 探索を開始するノード.ppがオブジェクト要素(JSON_VALUE_OBJ)なら,次のノードから探索する.
key 探索するノード名.
needval TRUE の場合,ノードが値(属性値)を持っていない場合は無視する."", '' の場合も無視する.
nn 一致するノード内,何番目を返すか指定する.nn<=0 は nn==1 とみなす.
Returns:
見つかったノードへのポインタ.見つからない場合は,NULL

Definition at line 981 of file tjson.c.

References _json_check_node_bykey(), _search_key_json(), and JSON_VALUE_OBJ.

Referenced by get_key_json_val(), and search_double_key_json().

00982 {
00983     if (pp==NULL || key==NULL) return NULL;
00984     if (nn<=0) nn = 1;
00985 
00986     // 開始ノードのチェック
00987     if (!(pp->ldat.lv==JSON_VALUE_OBJ && needval)){
00988         nn = _json_check_node_bykey(pp, key, needval, nn);
00989     }
00990     // 子ノード
00991     if (nn>0 && pp->next!=NULL) {
00992         pp = _search_key_json(pp->next, key, needval, &nn);
00993     }
00994     else return NULL;
00995 
00996     return pp; 
00997 }

Here is the call graph for this function:

Here is the caller graph for this function:

tJson* search_key_json_obj ( tJson pp,
char *  key,
int  nn 
)

tJson* search_key_json_obj(tJson* pp, char* key, int nn)

pp が指すノード以下で,名前(属性名)が key である nn番目のオブジェクトノードへのポインタを返す. pp の姉妹ノードは探索しない. search_key_json() よりは少し早い.たぶん.

Parameters:
pp 探索を開始するノード.
key 探索するノード名.
nn 一致するノード内,何番目を返すか指定する.nn<=0 は nn==1 とみなす.
Returns:
見つかったオブジェクトノードへのポインタ.見つからない場合は,NULL

Definition at line 1099 of file tjson.c.

References _json_check_node_bykey(), _search_key_json_obj(), FALSE, and JSON_VALUE_OBJ.

Referenced by search_double_key_json().

01100 {
01101     if (pp==NULL || key==NULL) return NULL;
01102     if (nn<=0) nn = 1;
01103 
01104     // 開始ノードのチェック
01105     if (pp->ldat.lv==JSON_VALUE_OBJ) {
01106         nn = _json_check_node_bykey(pp, key, FALSE, nn);
01107     }
01108     if (nn==0) return pp;
01109 
01110     // 子ノード
01111     if (pp->next!=NULL) {
01112         pp = _search_key_json_obj(pp->next, key, &nn);
01113     }
01114     else return NULL;
01115 
01116     return pp; 
01117 }

Here is the call graph for this function:

Here is the caller graph for this function:

tJson* search_key_sister_json ( tJson pp,
char *  key,
int  needval 
)

tJson* search_key_sister_json(tJson* pp, char* key, int needval)

pp が指すノードの姉妹で,名前(属性名)が key であるノードへのポインタを返す. 探索対象は探索を開始した姉妹ノードのみ. needval が TRUE の場合は,値(属性値)を持っている場合のみカウントする.

Parameters:
pp 探索を開始するノード.
key 探索するノード名.
needval TRUE の場合,ノードが値(属性値)を持っていない場合は無視する."", '' の場合も無視する.
Returns:
見つかったノードへのポインタ.見つからない場合は,NULL

Definition at line 1071 of file tjson.c.

References _json_check_node_bykey().

Referenced by get_key_sister_json_val(), and search_key_child_json().

01072 {
01073     if (pp==NULL || key==NULL) return NULL;
01074     while(pp->esis!=NULL) pp = pp->esis;
01075 
01076     while(pp!=NULL) {
01077         int nn = _json_check_node_bykey(pp, key, needval, 1);
01078         if (nn==0) return pp;
01079         pp = pp->ysis;
01080     }
01081     
01082     return NULL; 
01083 }

Here is the call graph for this function:

Here is the caller graph for this function:

tJson* search_sister_json ( tJson pp,
int  nn 
)

tJson* search_sister_json(tJson* pp, int nn)

nn個先の sister ノードを返す.正数の場合は younger sister,負数の場合は elder sister を検索する.

Parameters:
pp 探索を開始するノード.
nn 何個先の sister かを指定する.正数の場合は younger sister,負数の場合は elder sister.
Returns:
sister ノードへのポインタ.存在しない場合は NULL

Definition at line 1011 of file tjson.c.

01012 {
01013     if (pp==NULL) return NULL;
01014 
01015     if (nn>0) {
01016         int i = 0;
01017         while (pp!=NULL && i<nn) {
01018             pp = pp->ysis;
01019             i++;
01020         }
01021     }
01022     else if (nn<0) {
01023         nn = -nn;
01024         int i = 0;
01025         while (pp!=NULL && i<nn) {
01026             pp = pp->esis;
01027             i++;
01028         }
01029     }
01030     return pp;
01031 }

tJson* search_top_bracket_json ( tJson pp,
int  nn 
)

tJson* search_top_bracket_json(tJson* pp, int nn)

ツリーが複数のルート(TOP)を持つ場合(state==JBXL_JSON_MULTI_ROOT),指定された順番のTOPへのポインタを返す.

Parameters:
nn 何番目のTOPを返すか指定する.nn<=0 は nn==1 とみなす.
Returns:
見つかったノードへのポインタ.見つからない場合は,NULL

Definition at line 940 of file tjson.c.

References JSON_ANCHOR_NODE, and JSON_BRACKET_NODE.

00941 {
00942     if (pp==NULL) return NULL;
00943     if (nn<=0) nn = 1;
00944 
00945     while (pp->prev!=NULL) pp = pp->prev;
00946 
00947     if (pp->ldat.id==JSON_ANCHOR_NODE) {
00948         pp = pp->next;
00949     }
00950     if (pp->ldat.id==JSON_BRACKET_NODE) {
00951         while(pp->esis!=NULL) pp = pp->esis;
00952     }
00953     else {
00954         return NULL;
00955     }
00956 
00957     int i = 1;
00958     while (i<nn && pp!=NULL) {
00959         pp = pp->ysis;
00960         i++;
00961     }
00962 
00963     return pp;
00964 }


Generated on 15 Nov 2023 for JunkBox_Lib by  doxygen 1.6.1