Skip to content

Commit 41e1160

Browse files
committed
put CString and CException behind namespace
1 parent 89f15e9 commit 41e1160

File tree

11 files changed

+48
-27
lines changed

11 files changed

+48
-27
lines changed

include/maxplus/algebra/mpmatrix.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@
4747
#include <unordered_set>
4848
#include <vector>
4949

50-
class CString;
5150

5251
namespace MaxPlus {
5352

53+
class CString;
54+
5455
using namespace Graphs;
5556

5657
/**

include/maxplus/base/exception/exception.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
#include "../string/cstring.h"
4545
#include <exception>
4646

47+
48+
namespace MaxPlus {
49+
4750
/*
4851
* CException
4952
* CException container class.
@@ -94,11 +97,13 @@ class CException : std::exception {
9497
friend std::ostream &operator<<(std::ostream &stream, const CException &e);
9598
};
9699

100+
} // namespace MaxPlus
101+
97102
#define ASSERT(condition, msg) \
98103
{ \
99104
if (!(condition)) \
100-
throw CException(CString(__FILE__) + CString(":") + CString(__LINE__) + CString(": ") \
101-
+ CString(msg)); \
105+
throw MaxPlus::CException(MaxPlus::CString(__FILE__) + MaxPlus::CString(":") + MaxPlus::CString(__LINE__) + MaxPlus::CString(": ") \
106+
+ MaxPlus::CString(msg)); \
102107
}
103108

104109
#define EXCEPTION(msg, ...) \

include/maxplus/base/fraction/fraction.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
#include <climits>
4848
#include <cstdint>
4949

50+
namespace MaxPlus {
51+
5052
class CFraction {
5153
public:
5254
// Constructor
@@ -279,4 +281,6 @@ using CFractions = std::vector<CFraction>;
279281
using CFractionsIter = CFractions::iterator;
280282
using CFractionsCIter = CFractions::const_iterator;
281283

284+
} // namespace MaxPlus
285+
282286
#endif

include/maxplus/base/fsm/fsm.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class SetOfStates : public Abstract::SetOfStates {
379379
if (this->labelIndex.find(l) != this->labelIndex.end()) {
380380
return *this->labelIndex[l];
381381
}
382-
throw CException("error - state not found in FiniteStateMachine::_withLabel");
382+
throw MaxPlus::CException("error - state not found in FiniteStateMachine::_withLabel");
383383
}
384384

385385
bool hasStateWithLabel(StateLabelType l) {
@@ -544,7 +544,7 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
544544

545545
[[nodiscard]] StateRef<StateLabelType, EdgeLabelType> getInitialState() const override {
546546
if (this->initialStates.empty()) {
547-
throw CException("FSM has no initial state.");
547+
throw MaxPlus::CException("FSM has no initial state.");
548548
}
549549
auto s = this->initialStates.begin();
550550
return dynamic_cast<StateRef<StateLabelType, EdgeLabelType>>(*s);
@@ -955,34 +955,34 @@ namespace StateStringLabeled {
955955
// make an FSM class with unlabeled edges, based on the labeled one with some dummy char labels
956956
//
957957

958-
class State : public Labeled::State<CString, char> {
958+
class State : public Labeled::State<MaxPlus::CString, char> {
959959
public:
960-
explicit State(const CString &withLabel) : Labeled::State<CString, char>(withLabel) {}
960+
explicit State(const MaxPlus::CString &withLabel) : Labeled::State<MaxPlus::CString, char>(withLabel) {}
961961

962962
const Abstract::SetOfEdgeRefs &getOutgoingEdges() {
963963
return dynamic_cast<const Abstract::SetOfEdgeRefs &>(
964-
Labeled::State<CString, char>::getOutgoingEdges());
964+
Labeled::State<MaxPlus::CString, char>::getOutgoingEdges());
965965
}
966966
};
967967

968-
class FiniteStateMachine : public Labeled::FiniteStateMachine<CString, char> {
968+
class FiniteStateMachine : public Labeled::FiniteStateMachine<MaxPlus::CString, char> {
969969
public:
970-
[[nodiscard]] Labeled::StateRef<CString, char> getInitialState() const override {
971-
return dynamic_cast<Labeled::StateRef<CString, char>>(Labeled::FiniteStateMachine<CString, char>::getInitialState());
970+
[[nodiscard]] Labeled::StateRef<MaxPlus::CString, char> getInitialState() const override {
971+
return dynamic_cast<Labeled::StateRef<MaxPlus::CString, char>>(Labeled::FiniteStateMachine<MaxPlus::CString, char>::getInitialState());
972972
};
973973

974-
void setInitialStateLabeled(const CString &sl);
974+
void setInitialStateLabeled(const MaxPlus::CString &sl);
975975

976-
void addStateLabeled(const CString &sl);
976+
void addStateLabeled(const MaxPlus::CString &sl);
977977

978978
void addEdge(State *src, State *dst);
979979

980-
void addEdgeLabeled(const CString &src, const CString &dst);
980+
void addEdgeLabeled(const MaxPlus::CString &src, const MaxPlus::CString &dst);
981981

982982
std::shared_ptr<Abstract::SetOfStateRefs> reachableStates();
983983
};
984984

985-
class Edge : public Labeled::Edge<CString, char> {};
985+
class Edge : public Labeled::Edge<MaxPlus::CString, char> {};
986986
} // namespace StateStringLabeled
987987

988988
namespace Product {

include/maxplus/base/fsm/iofsm.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
#include <utility>
88

99
// Input/Output Automaton
10-
using InputAction = CString;
11-
using OutputAction = CString;
10+
using InputAction = MaxPlus::CString;
11+
using OutputAction = MaxPlus::CString;
1212
using IOAEdgeLabel = std::pair<InputAction, OutputAction>;
1313
using IOAState = ::FSM::Labeled::State<CId, IOAEdgeLabel>;
1414
using IOAStateRef = const IOAState*;
1515
using IOAEdge = ::FSM::Labeled::Edge<CId, IOAEdgeLabel>;
1616
using IOAEdgeRef = ::FSM::Labeled::EdgeRef<CId, IOAEdgeLabel>;
17-
using IOASetOfStates = ::FSM::Labeled::SetOfStates<CId, CString>;
18-
using IOASetOfStateRefs = ::FSM::Labeled::SetOfStateRefs<CId, CString>;
19-
using IOASetOfEdges = ::FSM::Labeled::SetOfEdges<CId, CString>;
17+
using IOASetOfStates = ::FSM::Labeled::SetOfStates<CId, MaxPlus::CString>;
18+
using IOASetOfStateRefs = ::FSM::Labeled::SetOfStateRefs<CId, MaxPlus::CString>;
19+
using IOASetOfEdges = ::FSM::Labeled::SetOfEdges<CId, MaxPlus::CString>;
2020
using IOASetOfEdgeRefs = ::FSM::Abstract::SetOfEdgeRefs;
2121

2222
namespace FSM::Labeled {

include/maxplus/base/string/cstring.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,11 @@
4141
#ifndef BASE_STRING_CSTRING_H
4242
#define BASE_STRING_CSTRING_H
4343

44-
#ifdef _MSC_VER
45-
#include <regex> // requires feature pack in VS2008
44+
#include "../basic_types.h"
45+
#include <regex>
4646
#include <string>
4747

48-
#else
49-
#include <cstring>
50-
#endif
51-
52-
#include "../basic_types.h"
48+
namespace MaxPlus {
5349

5450
// Forward class definition
5551
class CString;
@@ -171,4 +167,6 @@ inline CString operator+(const char *lhs, const CString &rhs) {
171167
// Tokenize a string
172168
void stringTok(CStrings &l, const CString &str, const char *tok = " \t\n");
173169

170+
} // namespace MaxPlus
171+
174172
#endif

src/base/analysis/mcm/mcmhoward.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
#include <cstdlib>
6060
#include <memory>
6161

62+
using namespace MaxPlus;
63+
6264
namespace Graphs {
6365
/*
6466
* Howard terminates with an error if MAX_NIterations occur.

src/base/exception/exception.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@
4040

4141
#include "base/exception/exception.h"
4242

43+
namespace MaxPlus {
44+
4345
// Prototype
4446
std::ostream &operator<<(std::ostream &stream, const CException &e) {
4547
e.report(stream);
4648

4749
return stream;
4850
}
51+
52+
} // namespace MaxPlus

src/base/fsm/fsm.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#include <memory>
4343
#include <string>
4444

45+
using namespace MaxPlus;
46+
4547
namespace FSM {
4648

4749
CId FSM::Abstract::WithUniqueID::nextID = 0;

src/base/string/cstring.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
#include <regex>
4646
#include <sstream>
4747

48+
namespace MaxPlus {
49+
4850
/**
4951
* CString ()
5052
* Constructor.
@@ -563,3 +565,5 @@ CString CString::regexReplaceMultiLine(const CString &regex, const CString &repl
563565
return *this;
564566
}
565567
}
568+
569+
} // namespace MaxPlus

0 commit comments

Comments
 (0)