@@ -137,7 +137,8 @@ struct Column<'a> {
137
137
subtable : Option < Table < ' a > > ,
138
138
domain : Option < RefCell < Domain < ' a > > > ,
139
139
bbox : Option < BBox > ,
140
- multitype : bool
140
+ multitype : bool ,
141
+ used : RefCell < bool >
141
142
}
142
143
143
144
#[ derive( Debug ) ]
@@ -412,7 +413,7 @@ fn add_table<'a>(name: &str, rowpath: &str, outfile: Option<&str>, settings: &Se
412
413
eprintln ! ( "Warning: the bbox option has no function without conversion type 'gml-to-ekwb'" ) ;
413
414
}
414
415
415
- let column = Column { name : colname. to_string ( ) , path, serial, datatype, value : RefCell :: new ( String :: new ( ) ) , attr, hide, include, exclude, trim, convert, find, replace, aggr, subtable, domain, bbox, multitype } ;
416
+ let column = Column { name : colname. to_string ( ) , path, serial, datatype, attr, hide, include, exclude, trim, convert, find, replace, aggr, subtable, domain, bbox, multitype, .. Default :: default ( ) } ;
416
417
table. columns . push ( column) ;
417
418
}
418
419
@@ -588,6 +589,7 @@ fn main() {
588
589
}
589
590
buf. clear ( ) ;
590
591
}
592
+ if !state. settings . hush_warning { check_columns_used ( & maintable) ; }
591
593
if !state. settings . hush_info {
592
594
let elapsed = start. elapsed ( ) . as_secs_f32 ( ) ;
593
595
eprintln ! ( "Info: [{}] {} rows processed in {:.*} seconds{}{}" ,
@@ -601,6 +603,18 @@ fn main() {
601
603
}
602
604
}
603
605
606
+ fn check_columns_used ( table : & Table ) {
607
+ for col in & table. columns {
608
+ if col. subtable . is_some ( ) {
609
+ let sub = col. subtable . as_ref ( ) . unwrap ( ) ;
610
+ check_columns_used ( sub) ;
611
+ }
612
+ else if !* col. used . borrow ( ) {
613
+ eprintln ! ( "Warning: table {} column {} was never found" , table. name, col. name) ;
614
+ }
615
+ }
616
+ }
617
+
604
618
fn process_event ( event : & Event , mut state : & mut State ) -> Step {
605
619
let table = & state. table ;
606
620
match event {
@@ -814,6 +828,9 @@ fn process_event(event: &Event, mut state: &mut State) -> Step {
814
828
}
815
829
if state. path == table. path { // This is an end tag of the row path
816
830
for i in 0 ..table. columns . len ( ) {
831
+ if !* table. columns [ i] . used . borrow ( ) && !table. columns [ i] . value . borrow ( ) . is_empty ( ) {
832
+ * state. table . columns [ i] . used . borrow_mut ( ) = true ;
833
+ }
817
834
if let Some ( re) = & table. columns [ i] . include {
818
835
if !re. is_match ( & table. columns [ i] . value . borrow ( ) ) {
819
836
state. filtered = true ;
0 commit comments