COPASI API  4.16.103
SBMLIncompatibility.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/SBMLIncompatibility.cpp,v $
3 // $Revision: 1.2 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2009/01/07 19:04:51 $
7 // End CVS Header
8 
9 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
11 // and The University of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc. and EML Research, gGmbH.
16 // All rights reserved.
17 
18 #include "SBMLIncompatibility.h"
19 #include "incompatibilities.h"
20 
21 #include <stdarg.h>
22 #include <stdio.h>
23 
24 #include "incompatibilities.h"
25 
26 #define INITIALTEXTSIZE 1024
27 
28 SBMLIncompatibility::SBMLIncompatibility(unsigned C_INT32 n, ...): mNumber(0), mMinSBMLLevel(0),
29  mMinSBMLVersion(0), mSeverity(SBMLIncompatibility::UNDEFINED), mMessage(""), mDetails("")
30 
31 {
32  const INCOMPATIBILITY* pTmp = &(Incompatibilities[0]);
33  while (pTmp->mNo != 9999)
34  {
35  if (pTmp->mNo == n)
36  {
37  break;
38  }
39  pTmp++;
40  }
41  mNumber = pTmp->mNo;
42  mMinSBMLLevel = pTmp->mSBMLLevel;
44  mSeverity = pTmp->mSeverity;
45  mDetails = pTmp->mDetails;
46  // now we have to create the message from the variable parameters
47  if (mNumber != 9999)
48  {
49  const char* fmt = pTmp->mMessage;
50 
51  C_INT32 TextSize = INITIALTEXTSIZE;
52  char *Text = new char[TextSize + 1];
53 
54  va_list args;
55  va_start(args, n);
56  C_INT32 Printed = vsnprintf(Text, TextSize, fmt, args);
57  va_end(args);
58 
59  while (Printed < 0 || TextSize < Printed)
60  {
61  delete [] Text;
62 
63  (Printed < 0) ? TextSize *= 2 : TextSize = Printed;
64  Text = new char[TextSize + 1];
65 
66  va_list args;
67  va_start(args, n);
68  Printed = vsnprintf(Text, TextSize, fmt, args);
69  va_end(args);
70  }
71 
72  mMessage = Text;
73  delete[] Text;
74  }
75 }
76 
78  {
79  return mMessage;
80  }
81 
83  {
84  return mDetails;
85  }
86 
88  {
89  return mSeverity;
90  }
91 
93  {
94  return mMinSBMLVersion;
95  }
96 
98  {
99  return mMinSBMLLevel;
100  }
unsigned C_INT32 minSBMLLevel() const
SEVERITY getSeverity() const
SBMLIncompatibility(unsigned C_INT32,...)
unsigned C_INT32 mSBMLLevel
unsigned C_INT32 mNumber
#define C_INT32
Definition: copasi.h:90
unsigned C_INT32 mSBMLVersion
unsigned C_INT32 minSBMLVersion() const
const char * mMessage
std::string getDetails() const
unsigned C_INT32 mNo
#define INITIALTEXTSIZE
const INCOMPATIBILITY Incompatibilities[]
const char * mDetails
std::string getMessage() const
unsigned C_INT32 mMinSBMLVersion
unsigned C_INT32 mMinSBMLLevel
SBMLIncompatibility::SEVERITY mSeverity