mimetypes/qmimemagicrulematcher.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#define QT_NO_CAST_FROM_ASCII -
43 -
44#include "qmimemagicrulematcher_p.h" -
45 -
46#include "qmimetype_p.h" -
47 -
48QT_BEGIN_NAMESPACE -
49 -
50/*! -
51 \internal -
52 \class QMimeMagicRuleMatcher -
53 \inmodule QtCore -
54 -
55 \brief The QMimeMagicRuleMatcher class checks a number of rules based on operator "or". -
56 -
57 It is used for rules parsed from XML files. -
58 -
59 \sa QMimeType, QMimeDatabase, MagicRule, MagicStringRule, MagicByteRule, GlobPattern -
60 \sa QMimeTypeParserBase, MimeTypeParser -
61*/ -
62 -
63QMimeMagicRuleMatcher::QMimeMagicRuleMatcher(const QString &mime, unsigned thePriority) : -
64 m_list(), -
65 m_priority(thePriority), -
66 m_mimetype(mime) -
67{ -
68}
never executed: }
0
69 -
70bool QMimeMagicRuleMatcher::operator==(const QMimeMagicRuleMatcher &other) const -
71{ -
72 return m_list == other.m_list &&
never executed: return m_list == other.m_list && m_priority == other.m_priority;
0
73 m_priority == other.m_priority;
never executed: return m_list == other.m_list && m_priority == other.m_priority;
0
74} -
75 -
76void QMimeMagicRuleMatcher::addRule(const QMimeMagicRule &rule) -
77{ -
78 m_list.append(rule);
never executed (the execution status of this line is deduced): m_list.append(rule);
-
79}
never executed: }
0
80 -
81void QMimeMagicRuleMatcher::addRules(const QList<QMimeMagicRule> &rules) -
82{ -
83 m_list.append(rules);
never executed (the execution status of this line is deduced): m_list.append(rules);
-
84}
never executed: }
0
85 -
86QList<QMimeMagicRule> QMimeMagicRuleMatcher::magicRules() const -
87{ -
88 return m_list;
never executed: return m_list;
0
89} -
90 -
91// Check for a match on contents of a file -
92bool QMimeMagicRuleMatcher::matches(const QByteArray &data) const -
93{ -
94 foreach (const QMimeMagicRule &magicRule, m_list) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(m_list)> _container_(m_list); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QMimeMagicRule &magicRule = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
95 if (magicRule.matches(data))
never evaluated: magicRule.matches(data)
0
96 return true;
never executed: return true;
0
97 }
never executed: }
0
98 -
99 return false;
never executed: return false;
0
100} -
101 -
102// Return a priority value from 1..100 -
103unsigned QMimeMagicRuleMatcher::priority() const -
104{ -
105 return m_priority;
never executed: return m_priority;
0
106} -
107 -
108QT_END_NAMESPACE -
109 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial