「String(API)」の版間の差分

提供: Eospedia
移動: 案内検索
(API)
(API)
 
(同じ利用者による、間の5版が非表示)
行12: 行12:
  
 
== API ==
 
== API ==
=== 文字列操作 ===
+
=== 初期化 ===
 
  extern void stringInit(String s, char* message);
 
  extern void stringInit(String s, char* message);
  
 +
=== ファイルからの文字列出力 ===
 +
fptInから読み出した文字列を出力します。<br>
 +
(mode&0x01: 0: 確認メッセージ有り, 1: 確認メッセージ無し): メッセージはfptOutに出力される。<br>
 +
fptIn = stdinとすると標準入力、fptout = stdoutとすると標準出力となります。
 
  extern String stringGetFromFile(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);
 
  extern String stringGetFromFile(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);
extern String stringGetFromFileWithSkippingComment(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);
 
 
  extern char* __getStringData(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);
 
  extern char* __getStringData(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);
  
 +
読み出した文字列からSTRING_WORD_SEPARATORを区切った1文字列を出力します。
 +
extern String stringGetFromFileWithSkippingComment(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);
 +
 +
=== 文字列抽出 ===
 +
文字列sからexceptionの各文字を区切り文字としたときにnth番目の文字列を出力します。
 
  extern String stringGetNthWord(char* s, long nth, char* exception);
 
  extern String stringGetNthWord(char* s, long nth, char* exception);
 +
 +
文字列sからexceptionの各文字を区切り文字としたときにnth番目の文字列を数値として出力します。
 
  extern double stringGetNthRealData(char* s, long nth, char* exception);
 
  extern double stringGetNthRealData(char* s, long nth, char* exception);
 
  extern long  stringGetNthIntegerData(char* s, long nth, char* exception);
 
  extern long  stringGetNthIntegerData(char* s, long nth, char* exception);
行29: 行39:
 
  extern double stringGetRealDataFromField(char* s, long init, long end);
 
  extern double stringGetRealDataFromField(char* s, long init, long end);
 
  extern long  stringGetIntegerDataFromField(char* s, long init, long end);
 
  extern long  stringGetIntegerDataFromField(char* s, long init, long end);
 
文字列s1とs2についてn文字目またはs1の文字数まで比較して、同じ場合は1を、それ以外で0を返します。
 
extern long stringIsSame(String s1, String s2, long n);
 
  
 
文字列sの文字数を出力します。
 
文字列sの文字数を出力します。
 
  extern long stringLength(String s);
 
  extern long stringLength(String s);
  
 +
=== 文字列比較 ===
 +
文字列s1とs2についてn文字目またはs1の文字数まで比較して、同じ場合は1を、それ以外で0を返します。
 +
extern long stringIsSame(String s1, String s2, long n);
 +
 +
=== 文字列コピー ===
 
文字列srcをdstへn文字分コピーします。(戻り値: コピーした文字数)
 
文字列srcをdstへn文字分コピーします。(戻り値: コピーした文字数)
 
  extern long stringCopy(String dst, String src, long n);
 
  extern long stringCopy(String dst, String src, long n);

2014年10月9日 (木) 02:14時点における最新版

General/Stringは文字列処理のためのAPI です。

定数

#define STRING_MAX_LENGTH (8192)
#define STRING_WORD_SEPARATOR  " ,\t" 
#define STRING_COMMENT_LINE_ID '#' 

構造体

typedef char*         String;
typedef unsigned long stringParaTypeInteger;
typedef float         stringParaTypeReal;

API

初期化

extern void stringInit(String s, char* message);

ファイルからの文字列出力

fptInから読み出した文字列を出力します。
(mode&0x01: 0: 確認メッセージ有り, 1: 確認メッセージ無し): メッセージはfptOutに出力される。
fptIn = stdinとすると標準入力、fptout = stdoutとすると標準出力となります。

extern String stringGetFromFile(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);
extern char* __getStringData(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);

読み出した文字列からSTRING_WORD_SEPARATORを区切った1文字列を出力します。

extern String stringGetFromFileWithSkippingComment(char* s, char* message, FILE* fptIn, FILE* fptOut, long mode);

文字列抽出

文字列sからexceptionの各文字を区切り文字としたときにnth番目の文字列を出力します。

extern String stringGetNthWord(char* s, long nth, char* exception);

文字列sからexceptionの各文字を区切り文字としたときにnth番目の文字列を数値として出力します。

extern double stringGetNthRealData(char* s, long nth, char* exception);
extern long   stringGetNthIntegerData(char* s, long nth, char* exception);

文字列sについてinit文字目からend文字目までを出力します。

extern String stringGetWordFromField(char* s, long init, long end);

文字列sについてinit文字目からend文字目までを数値として出力します。

extern double stringGetRealDataFromField(char* s, long init, long end);
extern long   stringGetIntegerDataFromField(char* s, long init, long end);

文字列sの文字数を出力します。

extern long stringLength(String s);

文字列比較

文字列s1とs2についてn文字目またはs1の文字数まで比較して、同じ場合は1を、それ以外で0を返します。

extern long stringIsSame(String s1, String s2, long n);

文字列コピー

文字列srcをdstへn文字分コピーします。(戻り値: コピーした文字数)

extern long stringCopy(String dst, String src, long n);

メモリを確保して、文字列srcを出力します。

extern String stringDuplicate(String src);