PostgreSQL/開発

概要

定義

マクロ

列挙型

構造体

stringinfo

番号データ型フィールド説明
1char*data文字列データのポインタ
2intlen文字列の長さ(\0終端)
3intmaxlenバッファ割り当ての最大長
4intcursorカーソル。makeStringInfoやinitStringInfoで0初期化される。
stringinfo.cルーチンの中で更新される訳ではなさそう。

関数

makeStringInfo

appendStringInfoCharMacro(str,ch)

initStringInfo

StringInfoData strdata;
initStringInfo(&strdata);
appendStringInfoCharMacro(&strdata, 'A');
elog(NOTICE, "%s", strdata.data);

resetStringInfo

typedef StringInfoData *StringInfo;

appendStringInfo

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

appendStringInfoVA

StringInfo *strinfo = makeStringInfo();

appendStringInfoString

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

appendStringInfoChar

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

appendStringInfoSpaces

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

appendBinaryStringInfo

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

enlargeStringInfo

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

サンプルプログラム

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

参考・関連

コメント



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