/[ascend]/trunk/pygtk/units.cpp
ViewVC logotype

Diff of /trunk/pygtk/units.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 965 by johnpye, Mon Apr 24 02:23:08 2006 UTC revision 966 by johnpye, Thu Dec 14 14:04:54 2006 UTC
# Line 7  using namespace std; Line 7  using namespace std;
7  #include "dimensions.h"  #include "dimensions.h"
8    
9  UnitsM::UnitsM(){  UnitsM::UnitsM(){
10      /// ctor required to keep SWIG happy. don't use it though.      int errcode;
11      throw runtime_error("Can't create new Units like this");      long unsigned pos;
12        u = FindOrDefineUnits("?",&pos,&errcode);
13        if(errcode){
14            // naughty to throw exceptions during ctor.
15            throw runtime_error("Can't create wildcard (?)");
16        }
17  }  }
18    
19  UnitsM::UnitsM(const struct Units *u) : u(u){  UnitsM::UnitsM(const struct Units *u) : u(u){
20      // nothing else      // nothing else
21  }  }
22    
23    /*
24    exception
25    UnitsM::getException(const int &errorcode, const char *ustr, const int &pos){
26        const char *s;
27        switch(errorcode){
28            case 0: return runtime_error("This error should not have been thrown!");
29            case 1: s = "Undefined unit used in string"; break;
30            case 2: s = "Unbalanced parenthesis"; break;
31            case 3: s = "Illegal character"; break;
32            case 4: s = "Illegal real value"; break;
33            case 5: s = "Oversized identifier or real"; break;
34            case 6: s = "Missing operator in real followed by identifier"; break;
35            case 7: s = "Term missing after * or / or ("; break;
36            case 8: s = "Term missing before * or /"; break;
37            case 9: s = "Too many closing parentheses"; break;
38            case 10: s = "Bad fraction exponent"; break;
39            case 11: raise runtime_error("Invalid UnitsM::getException errorcode = 11");
40        }
41        exception e = runtime_error(s);
42        CONSOLE_DEBUG("Units error: %s",s);
43        CONSOLE_DEBUG("%s",ustr);
44        char indic[strlen(ustr)+1];
45        for(int i=0; i<pos; ++i){
46            indic[i] = ' ';
47        }
48        indic[pos] = '^'; indic[pos+1] = '\0';
49        CONSOLE_DEBUG(indic);
50        return e;
51    }
52    */
53    
54  /**  /**
55      Parse a units string, create a new UnitsM object from the string.      Parse a units string, create a new UnitsM object from the string.
56    

Legend:
Removed from v.965  
changed lines
  Added in v.966

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22