tizen beta release
[framework/web/wrt-commons.git] / modules / vcore / src / vcore / SignatureFinder.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /*
17  * @file        SignatureFinder.h
18  * @author      Bartlomiej Grzelewski (b.grzelewski@samsung.com)
19  * @version     1.0
20  * @brief       Search for author-signature.xml and signatureN.xml files.
21  */
22 #ifndef _SIGNATUREFINDER_H_
23 #define _SIGNATUREFINDER_H_
24
25 #include <set>
26 #include <string>
27
28 #include <pcrecpp.h>
29
30 #include "SignatureData.h"
31
32 namespace ValidationCore {
33 class SignatureFileInfo
34 {
35   public:
36     SignatureFileInfo(const std::string &fileName,
37             int num) :
38         m_fileName(fileName),
39         m_fileNumber(num)
40     {
41     }
42
43     std::string getFileName() const
44     {
45         return m_fileName;
46     }
47
48     int getFileNumber() const
49     {
50         return m_fileNumber;
51     }
52
53     bool operator<(const SignatureFileInfo &second) const
54     {
55         return m_fileNumber < second.m_fileNumber;
56     }
57   private:
58     std::string m_fileName;
59     int m_fileNumber;
60 };
61
62 typedef std::set<SignatureFileInfo> SignatureFileInfoSet;
63
64 class SignatureFinder
65 {
66   public:
67     enum Result
68     {
69         NO_ERROR,
70         ERROR_OPENING_DIR,
71         ERROR_READING_DIR,
72         ERROR_ISTREAM
73     };
74
75     SignatureFinder(const std::string& dir);
76
77     Result find(SignatureFileInfoSet &set);
78
79   private:
80     std::string m_dir;
81     pcrecpp::RE m_signatureRegexp;
82 };
83 } // namespace ValidationCore
84
85 #endif