source: proto/parabix2/util/ErrorTracker.h @ 4183

Last change on this file since 4183 was 2280, checked in by ksherdy, 7 years ago

Updated include path and Makefile.

File size: 1.1 KB
Line 
1/*
2 * ErrorTracker.h
3 *
4 *  Created on: 2011-09-14
5 *      Author: ksherdy
6 */
7
8#ifndef ERRORTRACKER_H_
9#define ERRORTRACKER_H_
10
11#include "../lib/simd-lib/bitblock.hpp"
12#include "ErrorUtil.h"
13
14class ErrorTracker {
15public:
16
17        ErrorTracker() {
18                noted_pos_in_block = -1;
19        }
20
21        void NoteError(const char * error_msg, BitBlock err_strm) {
22                int pos_in_block = count_forward_zeroes(err_strm);
23                if ((noted_pos_in_block == -1) || (noted_pos_in_block > pos_in_block)) {
24                        noted_pos_in_block = pos_in_block;
25                        noted_error = error_msg;
26                }
27        }
28
29        int If_Error_Report_First(int error_line, int error_column) {
30                if (noted_pos_in_block > -1) {
31                        int error_line, error_column;
32                ReportError(noted_error, error_line, error_column);
33                return -1; // FAIL
34            }
35                return 0; // SUCCESS
36        }
37
38        inline bool Has_Noted_Error() {return (noted_pos_in_block > -1);}
39        inline int Noted_Pos_In_Block() const {return noted_pos_in_block;}
40        inline const char * Noted_Error_Msg() const {return noted_error;}
41
42private:
43  const char * noted_error;
44  int noted_pos_in_block;
45};
46
47#endif /* ERRORTRACKER_H_ */
Note: See TracBrowser for help on using the repository browser.