/*****************************************************************************/ /* Stream Class Library Copyright (c) 1999-2000 Sakai Hiroaki. */ /* All Rights Reserved. */ /*===========================================================================*/ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2, or (at your option) */ /* any later version. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program; see the file COPYING. If not, write to */ /* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /*****************************************************************************/ #ifndef _STREAM_H_INCLUDED_ #define _STREAM_H_INCLUDED_ /*****************************************************************************/ /* ここから */ /*****************************************************************************/ /*****************************************************************************/ /* Stream 型の定義 */ /*****************************************************************************/ typedef struct _Stream * Stream; /*****************************************************************************/ /* ヘッダファイルのインクルード */ /*****************************************************************************/ #include #include /*****************************************************************************/ /* 型の定義(外部に公開するもの) */ /*****************************************************************************/ /*===========================================================================*/ /* Stream 型の作成元のタイプ */ /*===========================================================================*/ typedef enum { CREATE_NO_STREAM, /* 作成元が無い */ CREATE_STREAM_FROM_FILE, /* ファイル名から作成 */ CREATE_STREAM_FROM_FILE_POINTER, /* ファイルポインタから作成 */ CREATE_STREAM_FROM_CHARACTERS /* 文字列(char * 型)から作成 */ } CreateStreamFrom; /*****************************************************************************/ /* 関数とメソッドの宣言(外部に公開するもの) */ /*****************************************************************************/ /*===========================================================================*/ /* オブジェクトの生成 */ /*===========================================================================*/ /*---------------------------------------------------------------------------*/ /* オブジェクトの生成 */ /*---------------------------------------------------------------------------*/ Stream Stream_Create(CreateStreamFrom from, void * object); /*---------------------------------------------------------------------------*/ /* なにもないところから生成(ダミー用) */ /*---------------------------------------------------------------------------*/ Stream Stream_CreateFromNone(); /*---------------------------------------------------------------------------*/ /* ファイルから生成 */ /*---------------------------------------------------------------------------*/ Stream Stream_CreateFromFile(char * filename); /*---------------------------------------------------------------------------*/ /* ファイルポインタから生成 */ /*---------------------------------------------------------------------------*/ Stream Stream_CreateFromFilePointer(FILE * fp); /*---------------------------------------------------------------------------*/ /* 文字列(char * 型)から生成 */ /*---------------------------------------------------------------------------*/ Stream Stream_CreateFromCharacters(char * characters); /*===========================================================================*/ /* オブジェクトの消去 */ /*===========================================================================*/ int Stream_Destroy(Stream this); /*===========================================================================*/ /* 文字列の取得 */ /*===========================================================================*/ /*---------------------------------------------------------------------------*/ /* 読み込む文字がまだあるかどうか */ /*---------------------------------------------------------------------------*/ int Stream_IsEnd(Stream this); /*---------------------------------------------------------------------------*/ /* Stream から1文字を取得(get)する. */ /*---------------------------------------------------------------------------*/ int Stream_GetCharacter(Stream this); /*---------------------------------------------------------------------------*/ /* Stream に1文字を返却(unget)する. */ /*---------------------------------------------------------------------------*/ int Stream_UngetCharacter(Stream this, int c); /*---------------------------------------------------------------------------*/ /* Stream に文字列を返却(unget)する. */ /*---------------------------------------------------------------------------*/ int Stream_UngetCharacters(Stream this, char * characters); /*---------------------------------------------------------------------------*/ /* Stream からトークンで区切って文字列を読み込み,文字列(String 型)で返す. */ /* 引用符やコメント行の解釈を行う. */ /*---------------------------------------------------------------------------*/ /* split1 は,複数の区切り文字が連続する場合にも,ヌル文字として切り分ける. */ /* split2 は,複数の区切り文字が連続する場合には,ひとつの区切り文字として */ /* 処理する. */ /*---------------------------------------------------------------------------*/ char * Stream_GetWord(Stream this, /* 読み込み元の Stream */ char * buffer, int buffer_length, char * split1, /* この文字で切り分ける */ char * split2, /* この文字でも切り分ける */ char * comment, /* コメント行の先頭文字 '#' など */ char * lineend, /* 行末文字 '\n' など */ char * quotation, /* 引用符文字 '\"' など */ char * head_skip, /* 文字列先頭の読みとばし文字 */ char * tail_skip /* 文字列末尾の読みとばし文字 */ ); /*****************************************************************************/ /* ここまで */ /*****************************************************************************/ #endif /*****************************************************************************/ /* End of File. */ /*****************************************************************************/