PostgreSQL/開発

概要

定義

マクロ

appendStringInfoCharMacro

appendStringInfoCharMacro(str,ch)

列挙型

構造体

StringInfoData

StringInfoは,StringInfoDataポインタの別名である

StringInfoData strdata;
initStringInfo(&strdata);
appendStringInfoCharMacro(&strdata, 'A');
elog(NOTICE, "%s", strdata.data);
番号データ型フィールド説明
1char*data文字列データのポインタ
2intlen文字列の長さ(\0終端)
3intmaxlenバッファ割り当ての最大長
4intcursor文字列バッファのカーソル,makeStringInfoやinitStringInfoで0初期化される。
stringinfo.cルーチンの中で都度更新されるフィールドでない

関数

makeStringInfo

typedef StringInfoData *StringInfo;

 サンプル 

// 引数1:
extern StringInfo makeStringInfo(void);

initStringInfo

StringInfo *strinfo = makeStringInfo();

 サンプル 

// 引数1:StringInfo構造体(StringInfoDataのポインタ)
extern void initStringInfo(StringInfo str);

resetStringInfo

StringInfo strinfo = (StringInfo) palloc(sizeof(StringInfoData));
initStringInfo(strinfo);

appendStringInfo

// 引数1:StringInfo構造体(StringInfoDataのポインタ)
extern void resetStringInfo(StringInfo str);

 サンプル 

// 引数1:StringInfo構造体(StringInfoDataのポインタ)
// 引数2〜:strに追加する文字列のフォーマット指定子と追加する文字列
extern void appendStringInfo(StringInfo str, const char *fmt,...) pg_attribute_printf(2, 3);

appendStringInfoVA

StringInfo strinfo = makeStringInfo();
appendStringInfo(strinfo, "%s", "hoge");
elog(NOTICE, "%s", strinfo->data);

appendStringInfoString

// 引数1:StringInfo構造体(StringInfoDataのポインタ)
// 引数2〜:strに追加する文字列のフォーマット指定子と追加する文字列
// 引数3:追加する文字列の可変長引数
// 戻り値:=0:書き込み成功,≠0 追加に必要とされる領域サイズ
extern int appendStringInfoVA(StringInfo str, const char *fmt, va_list args) pg_attribute_printf(2, 0);

appendStringInfoChar

// 引数1:StringInfo構造体(StringInfoDataのポインタ)
// 引数2:追加する文字列
extern void appendStringInfoString(StringInfo str, const char *s);

appendStringInfoSpaces

// 引数1:StringInfo構造体(StringInfoDataのポインタ)
// 引数2:追加する文字(シングルバイト)
extern void appendStringInfoChar(StringInfo str, char ch);

appendBinaryStringInfo

// 引数1:StringInfo構造体(StringInfoDataのポインタ)
// 引数2:追加するスペースサイズ
extern void appendStringInfoSpaces(StringInfo str, int count);

enlargeStringInfo

// 引数1:引数1:StringInfo構造体(StringInfoDataのポインタ)
// 引数2:追加する文字列
// 引数3:文字列のサイズ
extern void appendBinaryStringInfo(StringInfo str, const char *data, int datalen);

サンプルプログラム

// 引数1:引数1:StringInfo構造体(StringInfoDataのポインタ)
// 引数2:拡張するサイズ(バイト)
extern void enlargeStringInfo(StringInfo str, int needed);

参考・関連

コメント



トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
目次
ダブルクリックで閉じるTOP | 閉じる
GO TO TOP