File: mStr.h

package info (click to toggle)
aobook 1.0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,656 kB
  • sloc: ansic: 35,302; sh: 1,230; makefile: 300
file content (139 lines) | stat: -rw-r--r-- 5,605 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
/*$
Copyright (c) 2014-2017, Azel
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the <organization> nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
$*/

#ifndef MLIB_STR_H
#define MLIB_STR_H

#include "mStrDef.h"

#ifdef __cplusplus
extern "C" {
#endif

void mStrFree(mStr *str);
mBool mStrAlloc(mStr *str,int size);
void mStrInit(mStr *str);

mBool mStrResize(mStr *str,int len);
void mStrCalcLen(mStr *str);

mBool mStrIsEmpty(mStr *str);
void mStrEmpty(mStr *str);
void mStrSetLen(mStr *str,int len);
void mStrCopy(mStr *dst,mStr *src);
void mStrCopy_init(mStr *dst,mStr *src);
void mStrCopy_alloc(mStr *dst,mStr *src);

int mStrCharLenToByte(mStr *str,int len);
mBool mStrLimitBytes(mStr *str,int bytes);

char mStrGetLastChar(mStr *str);

void mStrSetChar(mStr *str,char c);
void mStrSetText(mStr *str,const char *text);
void mStrSetTextLen(mStr *str,const char *text,int len);
void mStrSetInt(mStr *str,int val);

void mStrSetTextWide(mStr *str,const void *text,int len);
void mStrSetTextLocal(mStr *str,const char *text,int len);
void mStrSetTextUCS4(mStr *str,const uint32_t *text,int len);
void mStrSetFormat(mStr *str,const char *format,...);
void mStrSetPercentEncoding(mStr *str,const char *text);
void mStrDecodePercentEncoding(mStr *str,const char *text);
void mStrDecodePercentEncoding_plus(mStr *str,const char *text);

int mStrSetURIList(mStr *str,const char *uri,mBool localfile);
void mStrSetURLEncode(mStr *str,const char *text);

void mStrAppendChar(mStr *str,char c);
void mStrAppendCharUCS4(mStr *str,uint32_t ucs);
void mStrAppendText(mStr *str,const char *text);
void mStrAppendTextLen(mStr *str,const char *text,int len);
void mStrAppendInt(mStr *str,int val);
void mStrAppendDouble(mStr *str,double d,int dig);
void mStrAppendStr(mStr *dst,mStr *src);
void mStrAppendTextLocal(mStr *str,const char *text,int len);
void mStrAppendFormat(mStr *str,const char *format,...);
void mStrPrependText(mStr *str,const char *text);

void mStrMid(mStr *dst,mStr *src,int pos,int len);
void mStrGetSplitText(mStr *dst,const char *text,char split,int index);

void mStrLower(mStr *str);
void mStrUpper(mStr *str);

int mStrToInt(mStr *str);
int mStrToIntArray(mStr *str,int *dst,int maxnum,char ch);
int mStrToIntArray_range(mStr *str,int *dst,int maxnum,char ch,int min,int max);

void mStrReplaceChar(mStr *str,char ch,char chnew);
void mStrReplaceSplitText(mStr *str,char split,int index,const char *text);
void mStrReplaceParams(mStr *str,char paramch,mStr *reparray,int arraynum);

int mStrFindChar(mStr *str,char ch);
int mStrFindCharRev(mStr *str,char ch);
void mStrFindCharToEnd(mStr *str,char ch);

mBool mStrCompareEq(mStr *str,const char *text);
mBool mStrCompareCaseEq(mStr *str,const char *text);

void mStrEscapeCmdline(mStr *str,const char *text);

void mStrPathSetHomeDir(mStr *str);
void mStrPathSetHomeDir_add(mStr *str,const char *path);
void mStrPathRemoveFileName(mStr *str);
void mStrPathRemoveBottomPathSplit(mStr *str);
void mStrPathReplaceDisableChar(mStr *str,char rep);
void mStrPathGetDir(mStr *dst,const char *path);
void mStrPathGetFileName(mStr *dst,const char *path);
void mStrPathGetFileNameNoExt(mStr *dst,const char *path);
void mStrPathGetExt(mStr *dst,const char *path);
void mStrPathSplitByDir(mStr *dst1,mStr *dst2,const char *path);
void mStrPathSplitByExt(mStr *dst1,mStr *dst2,const char *path);
void mStrPathAdd(mStr *dst,const char *path);
void mStrPathSetExt(mStr *path,const char *ext);
void mStrPathCombine(mStr *dst,const char *dir,const char *fname,const char *ext);
void mStrPathGetOutputFile(mStr *dst,const char *infile,const char *outdir,const char *outext);
mBool mStrPathCompareEq(mStr *str,const char *path);
mBool mStrPathCompareExtEq(mStr *path,const char *ext);
mBool mStrPathCompareExts(mStr *path,const char *exts);
mBool mStrPathExtractMultiFiles(mStr *dst,const char *text,int *param);

/*----*/

void mStrArrayFree(mStr *array,int num);
void mStrArrayInit(mStr *array,int num);
void mStrArrayCopy(mStr *dst,mStr *src,int num);
void mStrArrayShiftUp(mStr *array,int start,int end);
void mStrArraySetRecent(mStr *array,int arraynum,int index,const char *text);
void mStrArrayAddRecent(mStr *array,int arraynum,const char *text,mBool bPath);

#ifdef __cplusplus
}
#endif

#endif