9
9
// 1. Redistributions of source code must retain the above copyright notice,
10
10
// this list of conditions and the following disclaimer.
11
11
//
12
- // 2. Redistributions in binary form must reproduce the above copyright notice,
13
- // this list of conditions and the following disclaimer in the documentation
14
- // and/or other materials provided with the distribution.
12
+ // 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ // this list of conditions and the following disclaimer in the documentation
14
+ // and/or other materials provided with the distribution.
15
15
//
16
- // 3. Neither the name of the copyright holder nor the names of its contributors
17
- // may be used to endorse or promote products derived from this software
18
- // without specific prior written permission.
16
+ // 3. Neither the name of the copyright holder nor the names of its contributors
17
+ // may be used to endorse or promote products derived from this software
18
+ // without specific prior written permission.
19
19
//
20
20
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
21
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -56,8 +56,8 @@ namespace io{
56
56
57
57
namespace error {
58
58
struct base : std::exception{
59
- virtual void format_error_message ()const = 0;
60
-
59
+ virtual void format_error_message ()const = 0;
60
+
61
61
const char *what ()const noexcept override {
62
62
format_error_message ();
63
63
return error_message_buffer;
@@ -72,7 +72,7 @@ namespace io{
72
72
with_file_name (){
73
73
std::memset (file_name, 0 , sizeof (file_name));
74
74
}
75
-
75
+
76
76
void set_file_name (const char *file_name){
77
77
if (file_name != nullptr ){
78
78
strncpy (this ->file_name , file_name, sizeof (this ->file_name ));
@@ -89,7 +89,7 @@ namespace io{
89
89
with_file_line (){
90
90
file_line = -1 ;
91
91
}
92
-
92
+
93
93
void set_file_line (int file_line){
94
94
this ->file_line = file_line;
95
95
}
@@ -101,7 +101,7 @@ namespace io{
101
101
with_errno (){
102
102
errno_value = 0 ;
103
103
}
104
-
104
+
105
105
void set_errno (int errno_value){
106
106
this ->errno_value = errno_value;
107
107
}
@@ -214,7 +214,7 @@ namespace io{
214
214
try {
215
215
for (;;){
216
216
read_requested_condition.wait (
217
- guard,
217
+ guard,
218
218
[&]{
219
219
return desired_byte_count != -1 || termination_requested;
220
220
}
@@ -251,7 +251,7 @@ namespace io{
251
251
int finish_read (){
252
252
std::unique_lock<std::mutex>guard (lock);
253
253
read_finished_condition.wait (
254
- guard,
254
+ guard,
255
255
[&]{
256
256
return read_byte_count != -1 || read_error;
257
257
}
@@ -273,7 +273,7 @@ namespace io{
273
273
}
274
274
}
275
275
276
- private:
276
+ private:
277
277
std::unique_ptr<ByteSourceBase>byte_source;
278
278
279
279
std::thread worker;
@@ -286,7 +286,7 @@ namespace io{
286
286
287
287
std::mutex lock;
288
288
std::condition_variable read_finished_condition;
289
- std::condition_variable read_requested_condition;
289
+ std::condition_variable read_requested_condition;
290
290
};
291
291
#endif
292
292
@@ -504,7 +504,7 @@ namespace io{
504
504
with_column_name (){
505
505
std::memset (column_name, 0 , max_column_name_length+1 );
506
506
}
507
-
507
+
508
508
void set_column_name (const char *column_name){
509
509
if (column_name != nullptr ){
510
510
std::strncpy (this ->column_name , column_name, max_column_name_length);
@@ -524,7 +524,7 @@ namespace io{
524
524
with_column_content (){
525
525
std::memset (column_content, 0 , max_column_content_length+1 );
526
526
}
527
-
527
+
528
528
void set_column_content (const char *column_content){
529
529
if (column_content != nullptr ){
530
530
std::strncpy (this ->column_content , column_content, max_column_content_length);
@@ -691,7 +691,7 @@ namespace io{
691
691
constexpr static bool is_trim_char (char ){
692
692
return false ;
693
693
}
694
-
694
+
695
695
template <class ...OtherTrimChars>
696
696
constexpr static bool is_trim_char (char c, char trim_char, OtherTrimChars...other_trim_chars){
697
697
return c == trim_char || is_trim_char (c, other_trim_chars...);
@@ -720,7 +720,7 @@ namespace io{
720
720
constexpr static bool is_comment_start_char (char ){
721
721
return false ;
722
722
}
723
-
723
+
724
724
template <class ...OtherCommentStartChars>
725
725
constexpr static bool is_comment_start_char (char c, char comment_start_char, OtherCommentStartChars...other_comment_start_chars){
726
726
return c == comment_start_char || is_comment_start_char (c, other_comment_start_chars...);
@@ -782,8 +782,8 @@ namespace io{
782
782
}
783
783
++col_begin;
784
784
}while (*col_begin == quote);
785
- }
786
- return col_begin;
785
+ }
786
+ return col_begin;
787
787
}
788
788
789
789
static void unescape (char *&col_begin, char *&col_end){
@@ -803,7 +803,7 @@ namespace io{
803
803
*col_end = ' \0 ' ;
804
804
}
805
805
}
806
-
806
+
807
807
}
808
808
};
809
809
@@ -812,7 +812,7 @@ namespace io{
812
812
static void on_overflow (T&){
813
813
throw error::integer_overflow ();
814
814
}
815
-
815
+
816
816
template <class T >
817
817
static void on_underflow (T&){
818
818
throw error::integer_underflow ();
@@ -822,7 +822,7 @@ namespace io{
822
822
struct ignore_overflow {
823
823
template <class T >
824
824
static void on_overflow (T&){}
825
-
825
+
826
826
template <class T >
827
827
static void on_underflow (T&){}
828
828
};
@@ -832,7 +832,7 @@ namespace io{
832
832
static void on_overflow (T&x){
833
833
x = std::numeric_limits<T>::max ();
834
834
}
835
-
835
+
836
836
template <class T >
837
837
static void on_underflow (T&x){
838
838
x = std::numeric_limits<T>::min ();
@@ -850,12 +850,12 @@ namespace io{
850
850
col_begin = line;
851
851
// the col_begin + (... - col_begin) removes the constness
852
852
col_end = col_begin + (quote_policy::find_next_column_end (col_begin) - col_begin);
853
-
853
+
854
854
if (*col_end == ' \0 ' ){
855
855
line = nullptr ;
856
856
}else {
857
857
*col_end = ' \0 ' ;
858
- line = col_end + 1 ;
858
+ line = col_end + 1 ;
859
859
}
860
860
}
861
861
@@ -874,7 +874,7 @@ namespace io{
874
874
if (i != -1 ) {
875
875
trim_policy::trim (col_begin, col_end);
876
876
quote_policy::unescape (col_begin, col_end);
877
-
877
+
878
878
sorted_col[i] = col_begin;
879
879
}
880
880
}
@@ -899,7 +899,7 @@ namespace io{
899
899
900
900
trim_policy::trim (col_begin, col_end);
901
901
quote_policy::unescape (col_begin, col_end);
902
-
902
+
903
903
for (unsigned i=0 ; i<column_count; ++i)
904
904
if (col_begin == col_name[i]){
905
905
if (found[i]){
@@ -942,7 +942,7 @@ namespace io{
942
942
if (*col)
943
943
throw error::invalid_single_character ();
944
944
}
945
-
945
+
946
946
template <class overflow_policy >
947
947
void parse (char *col, std::string&x){
948
948
x = col;
@@ -985,7 +985,7 @@ namespace io{
985
985
{parse_unsigned_integer<overflow_policy>(col, x);}
986
986
template <class overflow_policy >void parse (char *col, unsigned long long &x)
987
987
{parse_unsigned_integer<overflow_policy>(col, x);}
988
-
988
+
989
989
template <class overflow_policy , class T >
990
990
void parse_signed_integer (const char *col, T&x){
991
991
if (*col == ' -' ){
@@ -1008,7 +1008,7 @@ namespace io{
1008
1008
}else if (*col == ' +' )
1009
1009
++col;
1010
1010
parse_unsigned_integer<overflow_policy>(col, x);
1011
- }
1011
+ }
1012
1012
1013
1013
template <class overflow_policy >void parse (char *col, signed char &x)
1014
1014
{parse_signed_integer<overflow_policy>(col, x);}
@@ -1037,7 +1037,7 @@ namespace io{
1037
1037
x += y;
1038
1038
++col;
1039
1039
}
1040
-
1040
+
1041
1041
if (*col == ' .' || *col == ' ,' ){
1042
1042
++col;
1043
1043
T pos = 1 ;
@@ -1054,7 +1054,7 @@ namespace io{
1054
1054
int e;
1055
1055
1056
1056
parse_signed_integer<set_to_max_on_overflow>(col, e);
1057
-
1057
+
1058
1058
if (e != 0 ){
1059
1059
T base;
1060
1060
if (e < 0 ){
@@ -1063,7 +1063,7 @@ namespace io{
1063
1063
}else {
1064
1064
base = T (10 );
1065
1065
}
1066
-
1066
+
1067
1067
while (e != 1 ){
1068
1068
if ((e & 1 ) == 0 ){
1069
1069
base = base*base;
@@ -1212,7 +1212,7 @@ namespace io{
1212
1212
void parse_helper (std::size_t ){}
1213
1213
1214
1214
template <class T , class ...ColType>
1215
- void parse_helper (std::size_t r, T&t, ColType&...cols){
1215
+ void parse_helper (std::size_t r, T&t, ColType&...cols){
1216
1216
if (row[r]){
1217
1217
try {
1218
1218
try {
@@ -1229,7 +1229,7 @@ namespace io{
1229
1229
parse_helper (r+1 , cols...);
1230
1230
}
1231
1231
1232
-
1232
+
1233
1233
public:
1234
1234
template <class ...ColType>
1235
1235
bool read_row (ColType& ...cols){
@@ -1239,17 +1239,17 @@ namespace io{
1239
1239
" too many columns specified" );
1240
1240
try {
1241
1241
try {
1242
-
1242
+
1243
1243
char *line;
1244
1244
do {
1245
1245
line = in.next_line ();
1246
1246
if (!line)
1247
1247
return false ;
1248
1248
}while (comment_policy::is_comment (line));
1249
-
1249
+
1250
1250
detail::parse_line<trim_policy, quote_policy>
1251
1251
(line, row, col_order);
1252
-
1252
+
1253
1253
parse_helper (0 , cols...);
1254
1254
}catch (error::with_file_name&err){
1255
1255
err.set_file_name (in.get_truncated_file_name ());
0 commit comments