ADT
        aaron-thesis
        arm-eh
        ast-experimental
        cleanup-dtors
        ctor
        deferred_resn
        demangler
        enum
        forall-pointer-decay
        gc_noraii
        jacob/cs343-translation
        jenkins-sandbox
        memory
        new-ast
        new-ast-unique-expr
        new-env
        no_list
        persistent-indexer
        pthread-emulation
        qualifiedEnum
        resolv-new
        string
        with_gc
      
      
        
          | 
            Last change
 on this file since fe3b61b was             51b73452, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago           | 
        
        
          | 
             
initial commit 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            1.0 KB
           | 
        
      
      
| Rev | Line |   | 
|---|
| [51b73452] | 1 | /*
 | 
|---|
 | 2 |  * This file is part of the Cforall project
 | 
|---|
 | 3 |  *
 | 
|---|
 | 4 |  * $Id: SemanticError.h,v 1.1 2002/04/27 19:57:10 rcbilson Exp $
 | 
|---|
 | 5 |  *
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | #ifndef SEMANTICERROR_H
 | 
|---|
 | 9 | #define SEMANTICERROR_H
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | #include <exception>
 | 
|---|
 | 12 | #include <string>
 | 
|---|
 | 13 | #include <strstream>
 | 
|---|
 | 14 | #include <list>
 | 
|---|
 | 15 | #include <iostream>
 | 
|---|
 | 16 | 
 | 
|---|
 | 17 | class SemanticError : public std::exception
 | 
|---|
 | 18 | {
 | 
|---|
 | 19 | public:
 | 
|---|
 | 20 |   SemanticError();
 | 
|---|
 | 21 |   SemanticError( std::string error );
 | 
|---|
 | 22 |   template< typename T > SemanticError( const std::string &error, const T *obj );
 | 
|---|
 | 23 |   ~SemanticError() throw() {}
 | 
|---|
 | 24 | 
 | 
|---|
 | 25 |   void append( SemanticError &other );
 | 
|---|
 | 26 |   bool isEmpty() const;
 | 
|---|
 | 27 |   void print( std::ostream &os );
 | 
|---|
 | 28 | 
 | 
|---|
 | 29 |   // constructs an exception using the given message and the printed
 | 
|---|
 | 30 |   // representation of the obj (T must have a print method)
 | 
|---|
 | 31 | 
 | 
|---|
 | 32 | private:
 | 
|---|
 | 33 |   std::list< std::string > errors;
 | 
|---|
 | 34 | };
 | 
|---|
 | 35 | 
 | 
|---|
 | 36 | template< typename T >
 | 
|---|
 | 37 | SemanticError::SemanticError( const std::string &error, const T *obj )
 | 
|---|
 | 38 | {
 | 
|---|
 | 39 |   std::ostrstream os;
 | 
|---|
 | 40 |   os << "Error: " << error;
 | 
|---|
 | 41 |   obj->print( os );
 | 
|---|
 | 42 |   errors.push_back( std::string( os.str(), os.pcount() ) );
 | 
|---|
 | 43 | }
 | 
|---|
 | 44 | 
 | 
|---|
 | 45 | #endif /* SEMANTICERROR_H */
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.