3 // Cassowary Incremental Constraint Solver
4 // Original Smalltalk Implementation by Alan Borning
5 // This C++ Implementation by Greg J. Badros, <gjb@cs.washington.edu>
6 // http://www.cs.washington.edu/homes/gjb
7 // (C) 1998, 1999 Greg J. Badros and Alan Borning
8 // See ../LICENSE for legal details regarding this software
15 #if defined(HAVE_CONFIG_H) && !defined(CONFIG_H_INCLUDED) && !defined(CONFIG_INLINE_H_INCLUDED)
16 #include <cassowary/config-inline.h>
17 #define CONFIG_INLINE_H_INCLUDED
20 #include "Cassowary.h"
21 #include "ClTypedefs.h"
28 class ExCLError : public exception {
30 ExCLError() : _msg(0) { }
31 virtual ~ExCLError() throw() {}
32 virtual string description() const
33 { return "(ExCLError) An error has occured in CL"; }
38 class ExCLInternalError : public ExCLError {
40 ExCLInternalError(const char *sz)
41 { _msg = strdup(sz); }
42 virtual string description() const
44 if (_msg) return _msg;
45 else return "(ExCLInternalError) An internal error has occurred";
49 class ExCLBadResolve : public ExCLError {
51 ExCLBadResolve(const char *sz)
52 { _msg = strdup(sz); }
53 virtual string description() const
55 if (_msg) return _msg;
56 else return "(ExCLBadResolve) Number of resolve values did not match number of edit vars";
60 class ExCLEditMisuse : public ExCLError {
62 ExCLEditMisuse(const char *sz)
63 { _msg = strdup(sz); }
64 virtual string description() const
66 if (_msg) return _msg;
67 return "(ExCLEditMisuse) Edit protocol usage violation";
71 class ExCLTooDifficult : public ExCLError {
73 virtual string description() const
74 { return "(ExCLTooDifficult) The constraints are too difficult to solve"; }
77 class ExCLTooDifficultSpecial : public ExCLTooDifficult {
79 ExCLTooDifficultSpecial(const char *sz)
80 { _msg = strdup(sz); }
81 virtual string description() const
83 if (_msg) return _msg;
84 else return "(ExCLTooDifficultSpecial) Solver requirements are not satisfied";
88 class ExCLReadOnlyNotAllowed : public ExCLTooDifficult {
90 virtual string description() const
91 { return "(ExCLReadOnlyNotAllowed) The read-only annotation is not permitted by the solver"; }
94 class ExCLCycleNotAllowed : public ExCLTooDifficult {
96 virtual string description() const
97 { return "(ExCLCycleNotAllowed) A cyclic constraint graph is not permitted by the solver"; }
100 class ExCLStrictInequalityNotAllowed : public ExCLTooDifficult {
102 virtual string description() const
103 { return "(ExCLStrictInequalityNotAllowed) The strict inequality is not permitted by the solver"; }
106 class ExCLRequiredFailure : public ExCLError {
108 virtual ~ExCLRequiredFailure() throw() {}
109 virtual string description() const
110 { return "(ExCLRequiredFailure) A required constraint cannot be satisfied"; }
113 class ExCLNotEnoughStays : public ExCLError {
115 virtual string description() const
116 { return "(ExCLNotEnoughStays) There are not enough stays to give specific values to every variable"; }
119 class ExCLNonlinearExpression : public ExCLError {
121 virtual string description() const
122 { return "(ExCLNonlinearExpression) The resulting expression would be nonlinear"; }
125 class ExCLConstraintNotFound : public ExCLError {
127 virtual string description() const
128 { return "(ExCLConstraintNotFound) Tried to remove a constraint that was never added"; }
131 class ExCLParseError : public ExCLError {
133 virtual ~ExCLParseError() throw() {}
134 virtual string description() const
135 { return "(ExCLParseError)"; }
138 class ExCLParseErrorMisc : public ExCLParseError {
140 ExCLParseErrorMisc(const string &s)
141 : _msg("(ExCLParseError) ")
143 virtual ~ExCLParseErrorMisc() throw() {}
144 virtual string description() const
150 class ExCLParseErrorBadIdentifier : public ExCLParseError {
152 ExCLParseErrorBadIdentifier(const string &id)
153 : _msg("(ExCLParseErrorBadIdentifier) Did not recognize identifier '")
158 virtual ~ExCLParseErrorBadIdentifier() throw() {}
159 virtual string description() const
165 class ExCLRequiredFailureWithExplanation : public ExCLRequiredFailure
168 virtual ~ExCLRequiredFailureWithExplanation() throw() {}
169 virtual string description() const
170 { return "(ExCLRequiredFailureWithExplanation) A required constraint cannot be satisfied"; }
171 virtual void AddConstraint(const ClConstraint *cnExpl)
172 { _explanation.insert(cnExpl); }
173 virtual const ClConstraintSet & explanation() const
174 { return _explanation; }
176 ClConstraintSet _explanation;