]>
git.saurik.com Git - android/aapt.git/blob - SourcePos.cpp
2761d182dec69eb1d3a4af5a68e755e8ff1adb46
  10 // ============================================================================= 
  19     ErrorPos(const ErrorPos
& that
); 
  20     ErrorPos(const String8
& file
, int line
, const String8
& error
, bool fatal
); 
  22     bool operator<(const ErrorPos
& rhs
) const; 
  23     bool operator==(const ErrorPos
& rhs
) const; 
  24     ErrorPos
& operator=(const ErrorPos
& rhs
); 
  26     void print(FILE* to
) const; 
  29 static vector
<ErrorPos
> g_errors
; 
  32     :line(-1), fatal(false) 
  36 ErrorPos::ErrorPos(const ErrorPos
& that
) 
  44 ErrorPos::ErrorPos(const String8
& f
, int l
, const String8
& e
, bool fat
) 
  57 ErrorPos::operator<(const ErrorPos
& rhs
) const 
  59     if (this->file 
< rhs
.file
) return true; 
  60     if (this->file 
== rhs
.file
) { 
  61         if (this->line 
< rhs
.line
) return true; 
  62         if (this->line 
== rhs
.line
) { 
  63             if (this->error 
< rhs
.error
) return true; 
  70 ErrorPos::operator==(const ErrorPos
& rhs
) const 
  72     return this->file 
== rhs
.file
 
  73             && this->line 
== rhs
.line
 
  74             && this->error 
== rhs
.error
; 
  78 ErrorPos::operator=(const ErrorPos
& rhs
) 
  80     this->file 
= rhs
.file
; 
  81     this->line 
= rhs
.line
; 
  82     this->error 
= rhs
.error
; 
  87 ErrorPos::print(FILE* to
) const 
  89     const char* type 
= fatal 
? "ERROR" : "WARNING"; 
  91     if (this->line 
>= 0) { 
  92         fprintf(to
, "%s:%d: %s %s\n", this->file
.string(), this->line
, type
, this->error
.string()); 
  94         fprintf(to
, "%s: %s %s\n", this->file
.string(), type
, this->error
.string()); 
  99 // ============================================================================= 
 100 SourcePos::SourcePos(const String8
& f
, int l
) 
 105 SourcePos::SourcePos(const SourcePos
& that
) 
 106     : file(that
.file
), line(that
.line
) 
 110 SourcePos::SourcePos() 
 111     : file("???", 0), line(-1) 
 115 SourcePos::~SourcePos() 
 120 SourcePos::error(const char* fmt
, ...) const 
 126     retval 
= vsnprintf(buf
, sizeof(buf
), fmt
, ap
); 
 128     char* p 
= buf 
+ retval 
- 1; 
 129     while (p 
> buf 
&& *p 
== '\n') { 
 133     g_errors
.push_back(ErrorPos(this->file
, this->line
, String8(buf
), true)); 
 138 SourcePos::warning(const char* fmt
, ...) const 
 144     retval 
= vsnprintf(buf
, sizeof(buf
), fmt
, ap
); 
 146     char* p 
= buf 
+ retval 
- 1; 
 147     while (p 
> buf 
&& *p 
== '\n') { 
 151     ErrorPos(this->file
, this->line
, String8(buf
), false).print(stderr
); 
 156 SourcePos::hasErrors() 
 158     return g_errors
.size() > 0; 
 162 SourcePos::printErrors(FILE* to
) 
 164     vector
<ErrorPos
>::const_iterator it
; 
 165     for (it
=g_errors
.begin(); it
!=g_errors
.end(); it
++) {