forked from vk-com/kphp-kdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring-processing.h
More file actions
79 lines (62 loc) · 2.74 KB
/
Copy pathstring-processing.h
File metadata and controls
79 lines (62 loc) · 2.74 KB
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
/*
This file is part of VK/KittenPHP-DB-Engine Library.
VK/KittenPHP-DB-Engine Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
VK/KittenPHP-DB-Engine Library 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with VK/KittenPHP-DB-Engine Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2010-2012 Vkontakte Ltd
2010-2012 Arseny Smirnov
2010-2012 Aliaksei Levin
2012 Anton Timofeev
2012 Sergey Kopeliovich
*/
/**
* Common string proccessing module.
* Implementation moved from logs-engine.
* Module prefix: 'sp' := 'string processing'
*
* Originally written: Arseny Smirnov & Alexey Levin
* Moved from log-engine: Anton Timofeev
* Created: 01.04.2012
*/
#pragma once
// Max preallocated size
#define STRING_PROCESS_BUF_SIZE 1000000
extern int sp_errno;
/**
* Simple memory management. Memory [pre]allocated from big static memory pool.
* All memory allocating and deallocating - just pool pointer shifting.
*/
// Sets pool pointer to the begin. "frees" all allocated memory.
// Must be called before allocating functions.
inline void sp_init (void);
// Preallocates 'len + 1' bytes. In fact, doesn't allocates anything,
// just checks whether there is enough available memory.
char *sp_str_pre_alloc (int len);
// Allocates 'len' bytes.
char *sp_str_alloc (int len);
// Returns sorted s string.
char *sp_sort (char *s);
// Returns upper/lower case string for s in cp1251.
char *sp_to_upper (char *s);
char *sp_to_lower (char *s);
/**
* Simplifications: look to source code to see full list of replacements.
*/
// Returns simplified s.
// Deletes all except digits, latin and russian letters in cp1251, lowercase letters.
char *sp_simplify (const char *s);
// Returns ultra-simplified s.
// Recognizes unicode characters encoded in cp1251 and html-entities. Remove diacritics
// from unicode characters, delete all except digits, latin and russian letters, lowercase
// letters. Unifies similar russian and english characters (i.e. ('n'|'ï') --> 'ï')
char *sp_full_simplify (const char *s);
// Converts all unicode characters encoded in cp1251 and html-entities into real cp1251,
// removing diacritics if possible. If converting is impossible - removes such characters.
char *sp_deunicode (char *s);