Skip to content

Commit a428666

Browse files
author
christian
committed
Add changes suggested by clang modernize
1 parent aa81fa5 commit a428666

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

csv.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace io{
5858
struct base : std::exception{
5959
virtual void format_error_message()const = 0;
6060

61-
const char*what()const throw(){
61+
const char*what()const noexcept override{
6262
format_error_message();
6363
return error_message_buffer;
6464
}
@@ -113,7 +113,7 @@ namespace io{
113113
base,
114114
with_file_name,
115115
with_errno{
116-
void format_error_message()const{
116+
void format_error_message()const override{
117117
if(errno_value != 0)
118118
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
119119
"Can not open file \"%s\" because \"%s\"."
@@ -129,7 +129,7 @@ namespace io{
129129
base,
130130
with_file_name,
131131
with_file_line{
132-
void format_error_message()const{
132+
void format_error_message()const override{
133133
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
134134
"Line number %d in file \"%s\" exceeds the maximum length of 2^24-1."
135135
, file_line, file_name);
@@ -443,7 +443,7 @@ namespace io{
443443

444444
char*next_line(){
445445
if(data_begin == data_end)
446-
return 0;
446+
return nullptr;
447447

448448
++file_line;
449449

@@ -542,9 +542,9 @@ namespace io{
542542
base,
543543
with_file_name,
544544
with_column_name{
545-
void format_error_message()const{
545+
void format_error_message()const override{
546546
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
547-
"Extra column \"%s\" in header of file \"%s\"."
547+
R"(Extra column "%s" in header of file "%s".)"
548548
, column_name, file_name);
549549
}
550550
};
@@ -553,9 +553,9 @@ namespace io{
553553
base,
554554
with_file_name,
555555
with_column_name{
556-
void format_error_message()const{
556+
void format_error_message()const override{
557557
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
558-
"Missing column \"%s\" in header of file \"%s\"."
558+
R"(Missing column "%s" in header of file "%s".)"
559559
, column_name, file_name);
560560
}
561561
};
@@ -564,17 +564,17 @@ namespace io{
564564
base,
565565
with_file_name,
566566
with_column_name{
567-
void format_error_message()const{
567+
void format_error_message()const override{
568568
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
569-
"Duplicated column \"%s\" in header of file \"%s\"."
569+
R"(Duplicated column "%s" in header of file "%s".)"
570570
, column_name, file_name);
571571
}
572572
};
573573

574574
struct header_missing :
575575
base,
576576
with_file_name{
577-
void format_error_message()const{
577+
void format_error_message()const override{
578578
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
579579
"Header missing in file \"%s\"."
580580
, file_name);
@@ -585,7 +585,7 @@ namespace io{
585585
base,
586586
with_file_name,
587587
with_file_line{
588-
void format_error_message()const{
588+
void format_error_message()const override{
589589
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
590590
"Too few columns in line %d in file \"%s\"."
591591
, file_line, file_name);
@@ -596,7 +596,7 @@ namespace io{
596596
base,
597597
with_file_name,
598598
with_file_line{
599-
void format_error_message()const{
599+
void format_error_message()const override{
600600
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
601601
"Too many columns in line %d in file \"%s\"."
602602
, file_line, file_name);
@@ -607,7 +607,7 @@ namespace io{
607607
base,
608608
with_file_name,
609609
with_file_line{
610-
void format_error_message()const{
610+
void format_error_message()const override{
611611
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
612612
"Escaped string was not closed in line %d in file \"%s\"."
613613
, file_line, file_name);
@@ -620,9 +620,9 @@ namespace io{
620620
with_file_line,
621621
with_column_name,
622622
with_column_content{
623-
void format_error_message()const{
623+
void format_error_message()const override{
624624
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
625-
"The integer \"%s\" must be positive or 0 in column \"%s\" in file \"%s\" in line \"%d\"."
625+
R"(The integer "%s" must be positive or 0 in column "%s" in file "%s" in line "%d".)"
626626
, column_content, column_name, file_name, file_line);
627627
}
628628
};
@@ -633,9 +633,9 @@ namespace io{
633633
with_file_line,
634634
with_column_name,
635635
with_column_content{
636-
void format_error_message()const{
636+
void format_error_message()const override{
637637
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
638-
"The integer \"%s\" contains an invalid digit in column \"%s\" in file \"%s\" in line \"%d\"."
638+
R"(The integer "%s" contains an invalid digit in column "%s" in file "%s" in line "%d".)"
639639
, column_content, column_name, file_name, file_line);
640640
}
641641
};
@@ -646,9 +646,9 @@ namespace io{
646646
with_file_line,
647647
with_column_name,
648648
with_column_content{
649-
void format_error_message()const{
649+
void format_error_message()const override{
650650
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
651-
"The integer \"%s\" overflows in column \"%s\" in file \"%s\" in line \"%d\"."
651+
R"(The integer "%s" overflows in column "%s" in file "%s" in line "%d".)"
652652
, column_content, column_name, file_name, file_line);
653653
}
654654
};
@@ -659,9 +659,9 @@ namespace io{
659659
with_file_line,
660660
with_column_name,
661661
with_column_content{
662-
void format_error_message()const{
662+
void format_error_message()const override{
663663
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
664-
"The integer \"%s\" underflows in column \"%s\" in file \"%s\" in line \"%d\"."
664+
R"(The integer "%s" underflows in column "%s" in file "%s" in line "%d".)"
665665
, column_content, column_name, file_name, file_line);
666666
}
667667
};
@@ -672,15 +672,15 @@ namespace io{
672672
with_file_line,
673673
with_column_name,
674674
with_column_content{
675-
void format_error_message()const{
675+
void format_error_message()const override{
676676
std::snprintf(error_message_buffer, sizeof(error_message_buffer),
677-
"The content \"%s\" of column \"%s\" in file \"%s\" in line \"%d\" is not a single character."
677+
R"(The content "%s" of column "%s" in file "%s" in line "%d" is not a single character.)"
678678
, column_content, column_name, file_name, file_line);
679679
}
680680
};
681681
}
682682

683-
typedef unsigned ignore_column;
683+
using ignore_column = unsigned int;
684684
static const ignore_column ignore_no_column = 0;
685685
static const ignore_column ignore_extra_column = 1;
686686
static const ignore_column ignore_missing_column = 2;
@@ -865,17 +865,17 @@ namespace io{
865865
char**sorted_col,
866866
const std::vector<int>&col_order
867867
){
868-
for(std::size_t i=0; i<col_order.size(); ++i){
868+
for (int i : col_order) {
869869
if(line == nullptr)
870870
throw ::io::error::too_few_columns();
871871
char*col_begin, *col_end;
872872
chop_next_column<quote_policy>(line, col_begin, col_end);
873873

874-
if(col_order[i] != -1){
874+
if (i != -1) {
875875
trim_policy::trim(col_begin, col_end);
876876
quote_policy::unescape(col_begin, col_end);
877877

878-
sorted_col[col_order[i]] = col_begin;
878+
sorted_col[i] = col_begin;
879879
}
880880
}
881881
if(line != nullptr)

0 commit comments

Comments
 (0)