~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/src/sip/pattern.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
 
2
 *  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
3
3
 *  Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com>
4
4
 *
5
5
 *  This program is free software; you can redistribute it and/or modify
78
78
        */
79
79
 
80
80
        Pattern(const std::string& pattern,
81
 
                const std::string& options = "");
 
81
                bool matchGlobally);
82
82
 
83
83
        /**
84
84
         * Destructor. Pcre pattern gets freed
87
87
        ~Pattern();
88
88
 
89
89
        /**
90
 
         * Assignment operator overloading.
91
 
         * Set the regular expression
92
 
         * to be used on subject strings
93
 
         * and compile the regular expression
94
 
         * from that string.
95
 
         *
96
 
         * @param pattern The new pattern
97
 
         */
98
 
        Pattern& operator=(const std::string& pattern) {
99
 
            pattern_ = pattern;
100
 
            compile();
101
 
            return *this;
102
 
        }
103
 
 
104
 
        Pattern& operator=(const char * pattern) {
105
 
            pattern_ = pattern;
106
 
            compile();
107
 
            return *this;
108
 
        }
109
 
 
110
 
        /**
111
 
         * Compile the regular expression
112
 
         * from the pattern that was set for
113
 
         * this object.
114
 
         */
115
 
        void compile();
116
 
 
117
 
        /**
118
 
         * Get the currently set regular expression
119
 
         * that is used on subject strings
120
 
         *
121
 
         * @return The currently set pattern
122
 
         */
123
 
        std::string getPattern() const {
124
 
            return pattern_;
125
 
        }
126
 
 
127
 
        /**
128
 
         * << operator overload. Sets the the subject
129
 
         * for latter use on the >> operator.
130
 
         *
131
 
         * @param subject
132
 
         *      The expression to be evaluated
133
 
         *      by the pattern.
134
 
         *
135
 
         */
136
 
        void operator<< (const std::string& subject) {
137
 
            subject_ = subject;
138
 
        }
139
 
 
140
 
        /**
141
 
         * Get the start position of the overall match.
142
 
         *
143
 
         * @return the start position of the overall match.
144
 
         */
145
 
        size_t start() const;
146
 
 
147
 
        /**
148
 
         * Get the start position of the specified match.
149
 
         *
150
 
         * @param groupNumber The capturing group number.
151
 
         *
152
 
         * @return the start position of the specified match.
153
 
         */
154
 
        size_t start(unsigned int groupNumber) const;
155
 
 
156
 
        /**
157
 
         * Get the start position of the specified match.
158
 
         *
159
 
         * @param groupName The capturing group name.
160
 
         */
161
 
        void start(const std::string& groupName) const;
162
 
 
163
 
        /**
164
 
         * Get the end position of the overall match.
165
 
         *
166
 
         * @return the end position of the overall match.
167
 
         */
168
 
        size_t end() const;
169
 
 
170
 
        /**
171
 
         * Get the end position of the specified match.
172
 
         *
173
 
         * @param groupNumber The capturing group number.
174
 
         *
175
 
         * @return the end position of the specified match.
176
 
         */
177
 
        size_t end(unsigned int groupNumber) const;
178
 
 
179
 
        /**
180
 
         * Get the end position of the specified match.
181
 
         *
182
 
         * @param groupName The capturing group name.
183
 
         *
184
 
         * @return the end position of the specified match.
185
 
         */
186
 
        void end(const std::string& groupName) const;
187
 
 
188
 
        /**
189
 
         * Get the number of capturing groups in the
190
 
         * compiled regex.
191
 
         *
192
 
         * @return The number of capture groups.
193
 
         *
194
 
         * @pre The regular expression should have been
195
 
         *          compiled prior to the execution of this method.
196
 
         */
197
 
        unsigned int getCaptureGroupCount();
198
 
 
199
 
        /**
200
90
         * Get the substring matched in a capturing
201
91
         * group (named or unnamed).
202
92
         *
212
102
         *         regular expression designated
213
103
         *         the group name.
214
104
         */
215
 
        std::string group(const std::string& groupName);
216
 
 
217
 
        /**
218
 
         * Get the substring matched in a named group.
219
 
         *
220
 
         * This methods only performs a basic lookup
221
 
         * inside its internal substring table. Thus,
222
 
         * matches() should have been called prior to
223
 
         * this method in order to obtain the desired
224
 
         * output.
225
 
         *
226
 
         * @param groupNumber The number of the group.
227
 
         *
228
 
         * @return the substring matched by the
229
 
         *         regular expression designated
230
 
         *         the group number.
231
 
         */
232
 
        std::string group(int groupNumber);
233
 
 
234
 
        /**
235
 
         * Similar to python's MatchObject.groups. Get all
236
 
         * the substrings matched by the capture groups defined
237
 
         * in the pattern. The complete (implicit) capture group
238
 
         * is not returned : ie only groups from 1 up to the number
239
 
         * of groups in the pattern are returned.
240
 
         *
241
 
         * @return A vector of stings that were matched by some
242
 
         *                 capturing group in the pattern.
243
 
         *
244
 
         * @pre The regular expression should have been
245
 
         *          compiled prior to the execution of this method.
246
 
         */
247
 
        std::vector<std::string> groups();
248
 
 
249
 
        /**
250
 
         * Try to match the compiled pattern with a
251
 
         * subject.
252
 
         *
253
 
         * @param subject Subject to be matched
254
 
         *                        by the pattern.
255
 
         *
256
 
         * @return true If the subject matches the pattern,
257
 
         *         false otherwise.
258
 
         *
259
 
         * @pre The regular expression should have been
260
 
         *          compiled prior to the execution of this method.
261
 
         *
262
 
         * @post The internal substring table will be updated
263
 
         *       with the new matches. Therefore, subsequent
264
 
         *               calls to group may return different results.
265
 
         */
266
 
        bool matches(const std::string& subject);
 
105
        std::string group(const char *groupName);
267
106
 
268
107
        /**
269
108
         * Try to match the compiled pattern with the implicit
295
134
         */
296
135
        std::vector<std::string> split();
297
136
 
 
137
        void updateSubject(const std::string& subject) {
 
138
            subject_ = subject;
 
139
        }
 
140
 
298
141
    private:
 
142
        /**
 
143
         * Get the start position of the overall match.
 
144
         *
 
145
         * @return the start position of the overall match.
 
146
         */
 
147
        size_t start() const;
 
148
 
 
149
        /**
 
150
         * Get the end position of the overall match.
 
151
         *
 
152
         * @return the end position of the overall match.
 
153
         */
 
154
        size_t end() const;
 
155
 
299
156
        NON_COPYABLE(Pattern);
300
157
         // The regular expression that represents that pattern.
301
158
        std::string pattern_;
319
176
        // The number of substrings matched after calling pcre_exec.
320
177
        int count_;
321
178
 
322
 
        // PCRE options for this pattern.
323
 
        int options_;
324
 
 
325
 
        // String representation of the options.
326
 
        std::string optionsDescription_;
 
179
        bool matchGlobally_;
327
180
};
328
181
}
329
182