File: Stream.h

package info (click to toggle)
xfireworks 1.3-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,036 kB
  • sloc: ansic: 6,896; makefile: 383; sh: 40
file content (156 lines) | stat: -rw-r--r-- 8,723 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*****************************************************************************/
/* 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 <stdio.h>
#include <stdlib.h>

/*****************************************************************************/
/* 型の定義(外部に公開するもの)                                              */
/*****************************************************************************/

/*===========================================================================*/
/* 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.                                                              */
/*****************************************************************************/