RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
ErrorLog.cpp
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2017 Roman Lebedev
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
21#include "ErrorLog.h"
22#include "adt/Mutex.h"
23#include <string>
24#include <utility>
25#include <vector>
26
27namespace rawspeed {
28
29void ErrorLog::setError(const std::string& err) {
30 MutexLocker guard(&mutex);
31 errors.push_back(err);
32}
33
34bool ErrorLog::isTooManyErrors(unsigned many, std::string* firstErr) {
35 MutexLocker guard(&mutex);
36
37 if (errors.size() < many)
38 return false;
39
40 if (!firstErr)
41 return true;
42
43 *firstErr = errors[0];
44 return true;
45}
46
47std::vector<std::string>&& ErrorLog::getErrors() {
48 MutexLocker guard(&mutex);
49 return std::move(errors);
50}
51
52} // namespace rawspeed
void setError(const std::string &err) REQUIRES(!mutex)
Definition ErrorLog.cpp:29
std::vector< std::string > && getErrors() REQUIRES(!mutex)
Definition ErrorLog.cpp:47
bool isTooManyErrors(unsigned many, std::string *firstErr=nullptr) REQUIRES(!mutex)
Definition ErrorLog.cpp:34