×

[PR]この広告は3ヶ月以上更新がないため表示されています。
ホームページを更新後24時間以内に表示されなくなります。

stringid.h
 1  #ifndef     __STRING_ID_DOUBLE_ARRAY_H_
 2  #define     __STRING_ID_DOUBLE_ARRAY_H_
 3  
 4  
 5  // Functions return these integers.
 6  #define     SI_OK       0       // No error.
 7  #define     SI_EHDL     ( -1 )  // Invalid handle.
 8  #define     SI_EMEM     ( -2 )  // Memory error.
 9  #define     SI_EIO      ( -3 )  // I/O error.
10  #define     SI_EARG     ( -4 )  // Invalid arguments.
11  #define     SI_EFMT     ( -5 )  // Invalid format.
12  #define     SI_EMAX     ( -6 )  // Size limit.
13  #define     SI_EVER     ( -7 )  // Version error.
14  #define     SI_EKEY     ( -8 )  // No such key.
15  
16  
17  #ifdef  __cplusplus
18  extern  "C" {
19  #endif
20  
21  
22  // Handle of key set.
23  typedef     struct SISet    *hSISet;
24  
25  // Handle of dictionary.
26  typedef     struct SIDic    *hSIDic;
27  
28  // Status of dictionary.
29  typedef     struct SIStat
30  {
31      int     nbc;        // Length of BC.
32      int     ntail;      // Length of TAIL.
33      int     size;       // Number of bytes allocated to BC and TAIL.
34      int     nkey;       // Number of keys.
35      int     maxlen;     // Length of the longest key.
36  }   SIStat, *hSIStat;
37  
38  // Agent for search.
39  typedef     struct SISrc
40  {
41      const char  *input;     // Input.
42      const char  *start;     // Start position of key.
43      int         len;        // Length of key.
44      int         idx;        // Index.
45      int         id;         // ID.
46  }   SISrc, *hSISrc;
47  
48  
49  // Create key set.
50  int     SISet_Open( hSISet *h );
51  // Load key set.
52  int     SISet_Load( hSISet h, const char *path, const char *delim );
53  // Insert key.
54  int     SISet_Insert( hSISet h, const char *key );
55  // Destroy key set.
56  int     SISet_Close( hSISet h );
57  
58  // Build dictionary.
59  int     SIDic_Build( hSIDic *h, hSISet set );
60  // Open dictionary.
61  int     SIDic_Open( hSIDic *h, const char *path );
62  // Destroy dictionary.
63  int     SIDic_Close( hSIDic h );
64  // Save dictionary.
65  int     SIDic_Save( hSIDic h, const char *path );
66  
67  // Get dictionary status.
68  int     SIDic_Status( hSIDic h, hSIStat st );
69  
70  // String to ID.
71  const char  *SIDic_StrToID( hSIDic h, const char *s, int *id );
72  // ID to string.
73  const char  *SIDic_IDToStr( hSIDic h, int id );
74  
75  // Start prefix and infix searches.
76  int     SISrc_Start( hSISrc h, const char *s );
77  // Search keys which are prefixes of input.
78  const char  *SIDic_Prefix( hSIDic h, hSISrc src );
79  // Search keys in input.
80  const char  *SIDic_Infix( hSIDic h, hSISrc src );
81  
82  // Error string.
83  const char  *SIDic_Error( int err );
84  
85  
86  #ifdef  __cplusplus
87  }
88  #endif
89  
90  
91  #endif