Skip to content

Commit

Permalink
clang tidy automatic fix only
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienLP committed Dec 13, 2019
1 parent b79af5a commit 96fc35f
Show file tree
Hide file tree
Showing 33 changed files with 106 additions and 72 deletions.
4 changes: 3 additions & 1 deletion base64_encode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ www.navitia.io
*/

#include "base64_encode.h"

#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/archive/iterators/ostream_iterator.hpp>
#include <boost/archive/iterators/transform_width.hpp>

#include <sstream>
#include <string>

Expand Down
5 changes: 3 additions & 2 deletions configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ www.navitia.io
*/

#include "configuration.h"
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>

#include <boost/foreach.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/ptree.hpp>

#ifdef WIN32
#include "windows.h"
Expand Down
5 changes: 3 additions & 2 deletions configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ www.navitia.io

#pragma once

#include <map>
#include <string>
#include <boost/lexical_cast.hpp>
#include <boost/thread/shared_mutex.hpp>

#include <map>
#include <string>

/** Configuration est un singleton : c'est à dire qu'on l'utilise
* Configuration * conf = Configuration::get();
* Au premier appel une instance sera créée
Expand Down
10 changes: 6 additions & 4 deletions coord_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@ www.navitia.io
*/

#include "coord_parser.h"

#include <boost/lexical_cast.hpp>

#include <utility>

namespace navitia {

wrong_coordinate::~wrong_coordinate() noexcept {}
wrong_coordinate::~wrong_coordinate() noexcept = default;

static std::pair<double, double> make_coord(const std::string& lon, const std::string& lat) {
try {
double dlon = boost::lexical_cast<double>(lon);
double dlat = boost::lexical_cast<double>(lat);
auto dlon = boost::lexical_cast<double>(lon);
auto dlat = boost::lexical_cast<double>(lat);
return {dlon, dlat};
} catch (const boost::bad_lexical_cast&) {
throw wrong_coordinate("conversion failed");
Expand All @@ -59,7 +61,7 @@ std::pair<double, double> parse_coordinate(const std::string& uri) {
if (uri.size() > 6 && uri.substr(0, 6) == "coord:") {
// old style to represent coord.
// done for retrocompatibility
size_t pos2 = uri.find(":", 6);
size_t pos2 = uri.find(':', 6);
if (pos2 != std::string::npos) {
return make_coord(uri.substr(6, pos2 - 6), uri.substr(pos2 + 1));
}
Expand Down
32 changes: 19 additions & 13 deletions csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ www.navitia.io
*/

#include "csv.h"
#include "logger.h"

#include "exception.h"
#include "functions.h"
#include <iostream>
#include "logger.h"

#include <boost/foreach.hpp>

#include <fstream>
#include <iostream>
#include <sstream>
#include <boost/foreach.hpp>

void CsvReader::init() {
// Our parser will fail (and thus throw) if a quoted string is not
Expand All @@ -60,7 +63,6 @@ CsvReader::CsvReader(const std::string& filename,
bool to_lower_headers,
std::string encoding)
: filename(filename),
file(),
separator(separator),
closed(false),
#ifdef HAVE_ICONV_H
Expand All @@ -84,8 +86,9 @@ CsvReader::CsvReader(const std::string& filename,
if (read_headers) {
auto line = next();
for (size_t i = 0; i < line.size(); ++i) {
if (to_lower_headers)
if (to_lower_headers) {
boost::to_lower(line[i]);
}
this->headers.insert(std::make_pair(line[i], i));
}
}
Expand All @@ -100,7 +103,6 @@ CsvReader::CsvReader(std::stringstream& sstream,
bool to_lower_headers,
std::string encoding)
: filename("sstream"),
file(),
separator(separator),
closed(false),
#ifdef HAVE_ICONV_H
Expand All @@ -119,8 +121,9 @@ CsvReader::CsvReader(std::stringstream& sstream,
if (read_headers) {
auto line = next();
for (size_t i = 0; i < line.size(); ++i) {
if (to_lower_headers)
if (to_lower_headers) {
boost::to_lower(line[i]);
}
this->headers.insert(std::make_pair(line[i], i));
}
}
Expand All @@ -132,17 +135,19 @@ bool CsvReader::is_open() const {

bool CsvReader::validate(const std::vector<std::string>& mandatory_headers) const {
BOOST_FOREACH (auto header, mandatory_headers) {
if (headers.find(header) == headers.end())
if (headers.find(header) == headers.end()) {
return false;
}
}
return true;
}

std::string CsvReader::missing_headers(const std::vector<std::string>& mandatory_headers) const {
std::string result;
BOOST_FOREACH (auto header, mandatory_headers) {
if (headers.find(header) == headers.end())
if (headers.find(header) == headers.end()) {
result += header + ", ";
}
}

return result;
Expand Down Expand Up @@ -196,9 +201,8 @@ std::pair<CsvReader::ParseStatus, std::vector<std::string>> CsvReader::get_line(
// then we need the next line to complete
if (e.first == s_end) {
return {ParseStatus::CONTINUE, {}};
} else {
return {ParseStatus::FAIL, {}};
}
return {ParseStatus::FAIL, {}};
}

if (!result || s_begin != s_end) {
Expand Down Expand Up @@ -251,8 +255,9 @@ std::vector<std::string> CsvReader::next() {

int CsvReader::get_pos_col(const std::string& str) const {
auto it = headers.find(str);
if (it != headers.end())
if (it != headers.end()) {
return it->second;
}
return -1;
}

Expand All @@ -267,8 +272,9 @@ bool CsvReader::is_valid(int col_idx, const std::vector<std::string>& row) const
void remove_bom(std::fstream& stream) {
char buffer[3];
stream.read(buffer, 3);
if (stream.gcount() != 3)
if (stream.gcount() != 3) {
return;
}
if (buffer[0] == '\xEF' && buffer[1] == '\xBB') {
// BOM UTF8
return;
Expand Down
13 changes: 8 additions & 5 deletions csv.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ www.navitia.io
#pragma once

#include "conf.h"

#ifdef HAVE_ICONV_H
#include "encoding_converter.h"
#endif

#include <boost/spirit/include/qi.hpp>
#include <boost/algorithm/string.hpp>

#include <string>
#include <fstream>
#include <sstream>
#include <vector>
#include <unordered_map>
#ifdef HAVE_ICONV_H
#include "encoding_converter.h"
#endif
#include <map>
#include <boost/spirit/include/qi.hpp>
#include <boost/algorithm/string.hpp>

/**
* lecteur CSV basique, si iconv est disponible, le resultat serat retourné en UTF8
Expand Down
5 changes: 3 additions & 2 deletions deadline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ IRC #navitia on freenode
www.navitia.io
*/

#include <boost/date_time/posix_time/posix_time.hpp>
#include "utils/deadline.h"

#include <boost/date_time/posix_time/posix_time.hpp>

namespace navitia {

DeadlineExpired::~DeadlineExpired() = default;

Deadline::Deadline() {}
Deadline::Deadline() = default;
Deadline::Deadline(const boost::posix_time::ptime& deadline) : deadline(deadline) {}
void Deadline::set(const boost::posix_time::ptime& deadline) {
this->deadline = deadline;
Expand Down
3 changes: 2 additions & 1 deletion deadline.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ www.navitia.io
*/

#pragma once
#include "utils/exception.h"

#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/optional.hpp>
#include "utils/exception.h"

namespace navitia {

Expand Down
5 changes: 3 additions & 2 deletions encoding_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ www.navitia.io
#include "encoding_converter.h"

#ifdef HAVE_ICONV_H
#include <string.h>
#include <cstring>
#include <fstream>
#include <limits>

EncodingConverter::EncodingConverter(std::string from, std::string to, size_t buffer_size) : buffer_size(buffer_size) {
EncodingConverter::EncodingConverter(const std::string& from, const std::string& to, size_t buffer_size)
: buffer_size(buffer_size) {
iconv_handler = iconv_open(to.c_str(), from.c_str());
iconv_input_buffer = new char[buffer_size];
iconv_output_buffer = new char[buffer_size];
Expand Down
2 changes: 1 addition & 1 deletion encoding_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ www.navitia.io
/// Classe permettant de convertir l'encodage de chaînes de caractères
class EncodingConverter {
public:
EncodingConverter(std::string from, std::string to, size_t buffer_size);
EncodingConverter(const std::string& from, const std::string& to, size_t buffer_size);
std::string convert(const std::string& str);
virtual ~EncodingConverter();

Expand Down
4 changes: 2 additions & 2 deletions exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace navitia {

exception::~exception() noexcept {}
recoverable_exception::~recoverable_exception() noexcept {}
exception::~exception() noexcept = default;
recoverable_exception::~recoverable_exception() noexcept = default;

} // namespace navitia
2 changes: 1 addition & 1 deletion exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ www.navitia.io
*/

#pragma once
#include "backtrace.h"

#include <string>
#include <exception>
#include "backtrace.h"

namespace navitia {
class exception : public std::exception {
Expand Down
5 changes: 3 additions & 2 deletions flat_enum_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ www.navitia.io
*/

#pragma once
#include <array>
#include <type_traits>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/array.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/range/iterator_range_core.hpp>

#include <array>
#include <type_traits>

namespace navitia {

// template <typename EnumKey> struct enum_size_trait {};
Expand Down
14 changes: 8 additions & 6 deletions functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ www.navitia.io
*/

#include "functions.h"

#include "alphanum.hpp"

#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/split.hpp>

double str_to_double(std::string str) {
boost::trim(str);
Expand Down Expand Up @@ -64,8 +66,9 @@ std::vector<std::string> split_string(const std::string& str, const std::string&
}

std::string value_by_key(const std::map<std::string, std::string>& vect, const std::string& key) {
if (vect.find(key) != vect.end())
if (vect.find(key) != vect.end()) {
return vect.at(key);
}
return "";
}

Expand All @@ -75,7 +78,7 @@ bool pseudo_natural_sort::operator()(const std::string& a, const std::string& b)
return doj::alphanum_less<std::string>()(a, b);
}
std::string make_adapted_uri_fast(const std::string& ref_uri, size_t s) {
return ref_uri + ":adapted-" + boost::lexical_cast<std::string>(s);
return ref_uri + ":adapted-" + std::to_string(s);
}

std::string make_adapted_uri(const std::string& ref_uri) {
Expand All @@ -89,10 +92,9 @@ std::string absolute_path() {
char buf[256];
if (getcwd(buf, sizeof(buf))) {
return std::string(buf) + "/";
} else {
std::perror("getcwd");
return "";
}
std::perror("getcwd");
return "";
}

} // namespace navitia
16 changes: 8 additions & 8 deletions functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ www.navitia.io

#pragma once

#include <iostream>
#include <vector>
#include <memory>
#include <map>
#include <algorithm>
#include <cstdio>
#include <unistd.h> // getcwd() definition

#include <boost/range/algorithm/remove_if.hpp>
#include <boost/range/algorithm/find_if.hpp>
#include <boost/weak_ptr.hpp>
Expand All @@ -47,6 +39,14 @@ www.navitia.io
#include <boost/uuid/uuid_io.hpp>
#include <boost/range/algorithm_ext/erase.hpp>

#include <iostream>
#include <vector>
#include <memory>
#include <map>
#include <algorithm>
#include <cstdio>
#include <unistd.h> // getcwd() definition

namespace google {
namespace protobuf {
template <typename Element>
Expand Down
1 change: 1 addition & 0 deletions get_hostname.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "get_hostname.h"

#include <unistd.h>

namespace navitia {
Expand Down
Loading

0 comments on commit 96fc35f

Please sign in to comment.