Modify RecordCorruptedException class hierarchy
[platform/core/security/cynara.git] / src / common / exceptions / BucketRecordCorruptedException.h
1 /*
2  * Copyright (c) 2014-2015 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        src/common/exceptions/BucketRecordCorruptedException.h
18  * @author      Aleksander Zdyb <a.zdyb@samsung.com>
19  * @author      Pawel Wieczorek <p.wieczorek2@samsung.com>
20  * @version     1.0
21  * @brief       Implementation of BucketRecordCorruptedException
22  */
23
24 #ifndef SRC_COMMON_EXCEPTIONS_BUCKETRECORDCORRUPTEDEXCEPTION_H_
25 #define SRC_COMMON_EXCEPTIONS_BUCKETRECORDCORRUPTEDEXCEPTION_H_
26
27 #include <string>
28
29 #include <exceptions/RecordCorruptedException.h>
30
31 namespace Cynara {
32
33 class BucketRecordCorruptedException : public RecordCorruptedException {
34 public:
35     BucketRecordCorruptedException() = delete;
36     virtual ~BucketRecordCorruptedException() {};
37
38     BucketRecordCorruptedException(const std::string &line) : RecordCorruptedException(line) {
39         setMessage(subtype());
40     }
41
42     BucketRecordCorruptedException withLineNumber(const size_t &lineNumber) const {
43         BucketRecordCorruptedException copy(*this);
44         copy.m_lineNumber = lineNumber;
45         copy.setMessage(copy.subtype());
46         return copy;
47     }
48
49     BucketRecordCorruptedException withFilename(const std::string &filename) const {
50         BucketRecordCorruptedException copy(*this);
51         copy.m_filename = filename;
52         copy.setMessage(copy.subtype());
53         return copy;
54     }
55
56 private:
57     const std::string &subtype(void) {
58         static const std::string subtype("Bucket");
59         return subtype;
60     }
61 };
62
63 } /* namespace Cynara */
64
65 #endif /* SRC_COMMON_EXCEPTIONS_BUCKETRECORDCORRUPTEDEXCEPTION_H_ */