comparison OrthancFramework/Sources/HttpServer/CStringMatcher.h @ 4652:0ad5736c8d62

use plain C strings in MultipartStreamReader instead of std::string to allow further optimizations
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 May 2021 11:50:14 +0200
parents
children 7053502fbf97
comparison
equal deleted inserted replaced
4651:365f51fae413 4652:0ad5736c8d62
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program. If not, see
19 * <http://www.gnu.org/licenses/>.
20 **/
21
22
23 #pragma once
24
25 #include "../OrthancFramework.h"
26
27 #include <boost/noncopyable.hpp>
28 #include <boost/shared_ptr.hpp>
29 #include <string>
30
31 namespace Orthanc
32 {
33 // Convenience class that wraps a Boost algorithm for string matching
34 class ORTHANC_PUBLIC CStringMatcher : public boost::noncopyable
35 {
36 private:
37 class Search;
38
39 boost::shared_ptr<Search> search_; // PImpl pattern
40 std::string pattern_;
41 bool valid_;
42 const char* matchBegin_;
43 const char* matchEnd_;
44
45 public:
46 explicit CStringMatcher(const std::string& pattern);
47
48 const std::string& GetPattern() const;
49
50 bool IsValid() const;
51
52 // "end" is non-inclusive
53 bool Apply(const char* start,
54 const char* end);
55
56 bool Apply(const std::string& corpus);
57
58 const char* GetMatchBegin() const;
59
60 const char* GetMatchEnd() const;
61 };
62 }