QueryParserUtils.h revision 2e75b752
1/*
2 * Copyright 2001-2014, Axel D��rfler, axeld@pinc-software.de.
3 * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
4 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
5 * This file may be used under the terms of the MIT License.
6 */
7#ifndef _FILE_SYSTEMS_QUERY_PARSER_UTILS_H
8#define _FILE_SYSTEMS_QUERY_PARSER_UTILS_H
9
10
11#include <sys/cdefs.h>
12
13#ifdef FS_SHELL
14#	include <new>
15
16#	include "fssh_api_wrapper.h"
17#	include "fssh_auto_deleter.h"
18#else
19#	include <SupportDefs.h>
20#endif	// !FS_SHELL
21
22
23namespace QueryParser {
24
25
26enum match {
27	NO_MATCH = 0,
28	MATCH_OK = 1,
29
30	MATCH_BAD_PATTERN = -2,
31	MATCH_INVALID_CHARACTER
32};
33
34// return values from isValidPattern()
35enum {
36	PATTERN_INVALID_ESCAPE = -3,
37	PATTERN_INVALID_RANGE,
38	PATTERN_INVALID_SET
39};
40
41
42__BEGIN_DECLS
43
44
45void		skipWhitespace(char** expr, int32 skip = 0);
46void		skipWhitespaceReverse(char** expr, char* stop);
47int			compareKeys(uint32 type, const void* key1, size_t length1,
48				const void* key2, size_t length2);
49uint32		utf8ToUnicode(char** string);
50int32		getFirstPatternSymbol(char* string);
51status_t	isValidPattern(char* pattern);
52status_t	matchString(char* pattern, char* string);
53
54
55__END_DECLS
56
57
58static inline bool
59isPattern(char* string)
60{
61	return getFirstPatternSymbol(string) >= 0 ? true : false;
62}
63
64
65}	// namespace QueryParser
66
67
68#endif	// _FILE_SYSTEMS_QUERY_PARSER_UTILS_H
69