Project

General

Profile

Statistics
| Branch: | Revision:

root / src / scave / scaveexception.h @ a3be1d55

History | View | Annotate | Download (1.74 KB)

1
//=========================================================================
2
//  SCAVEEXCEPTION.H - part of
3
//                  OMNeT++/OMNEST
4
//           Discrete System Simulation in C++
5
//
6
//  Author: Tamas Borbely
7
//
8
//=========================================================================
9

    
10
/*--------------------------------------------------------------*
11
  Copyright (C) 2006-2008 OpenSim Ltd.
12

13
  This file is distributed WITHOUT ANY WARRANTY. See the file
14
  `license' for details on this and other legal matters.
15
*--------------------------------------------------------------*/
16

    
17
#ifndef _SCAVEEXCEPTION_H_
18
#define _SCAVEEXCEPTION_H_
19

    
20
#include <string>
21
#include <exception>
22
#include <stdexcept>
23
#include "platmisc.h"
24
#include "commondefs.h"
25
#include "scavedefs.h"
26
#include "exception.h"
27

    
28
NAMESPACE_BEGIN
29

    
30
/**
31
 * Exception thrown when a syntax error found while reading a result file.
32
 */
33
class SCAVE_API ResultFileFormatException : public opp_runtime_error
34
{
35
  private:
36
      std::string file;
37
      int64 line;
38
      file_offset_t offset;
39

    
40
  public:
41
    /**
42
     * Constructor with error message and location.
43
     */
44
    ResultFileFormatException(const char *msg, const char *file, int64 line, file_offset_t offset = -1);
45

    
46
    /**
47
     * Destructor with throw clause required by gcc.
48
     */
49
    virtual ~ResultFileFormatException() throw() {}
50

    
51
    /**
52
     * Returns the name of the file in which the error occured.
53
     */
54
    const char *getFileName() const { return file.c_str(); }
55

    
56
    /**
57
     * Returns the line number at which the error occured.
58
     */
59
    int64 getLine() const { return line; }
60

    
61
    /**
62
     * Returns the file offset at which the error occured.
63
     */
64
    file_offset_t getFileOffset() const { return offset; }
65
};
66

    
67
NAMESPACE_END
68

    
69

    
70
#endif
71

    
72