Commit 5e8ce317 authored by snuverink_j's avatar snuverink_j
Browse files

small fixes; write std namespace explicitly

parent 960c5b75
...@@ -28,10 +28,7 @@ ...@@ -28,10 +28,7 @@
#include "Utilities/Round.h" #include "Utilities/Round.h"
#include <iostream> #include <iostream>
//using std::cerr; #include <vector>
//using std::endl;
using std::vector;
using namespace std;
extern Inform *gmsg; extern Inform *gmsg;
...@@ -41,7 +38,7 @@ extern Inform *gmsg; ...@@ -41,7 +38,7 @@ extern Inform *gmsg;
Object::~Object() { Object::~Object() {
// Invalidate all references to this object. // Invalidate all references to this object.
for(set<Invalidator *>::iterator i = references.begin(); for(std::set<Invalidator *>::iterator i = references.begin();
i != references.end(); ++i) { i != references.end(); ++i) {
(*i)->invalidate(); (*i)->invalidate();
} }
...@@ -64,8 +61,8 @@ void Object::execute() { ...@@ -64,8 +61,8 @@ void Object::execute() {
} }
Attribute *Object::findAttribute(const string &name) { Attribute *Object::findAttribute(const std::string &name) {
for(vector<Attribute>::iterator i = itsAttr.begin(); for(std::vector<Attribute>::iterator i = itsAttr.begin();
i != itsAttr.end(); ++i) { i != itsAttr.end(); ++i) {
if(i->getName() == name) return &(*i); if(i->getName() == name) return &(*i);
} }
...@@ -74,8 +71,8 @@ Attribute *Object::findAttribute(const string &name) { ...@@ -74,8 +71,8 @@ Attribute *Object::findAttribute(const string &name) {
} }
const Attribute *Object::findAttribute(const string &name) const { const Attribute *Object::findAttribute(const std::string &name) const {
for(vector<Attribute>::const_iterator i = itsAttr.begin(); for(std::vector<Attribute>::const_iterator i = itsAttr.begin();
i != itsAttr.end(); ++i) { i != itsAttr.end(); ++i) {
if(i->getName() == name) return &(*i); if(i->getName() == name) return &(*i);
} }
...@@ -85,13 +82,13 @@ const Attribute *Object::findAttribute(const string &name) const { ...@@ -85,13 +82,13 @@ const Attribute *Object::findAttribute(const string &name) const {
Object *Object::makeTemplate Object *Object::makeTemplate
(const string &name, TokenStream &, Statement &) { (const std::string &name, TokenStream &, Statement &) {
throw ParseError("Object::makeTemplate()", "Object \"" + name + throw ParseError("Object::makeTemplate()", "Object \"" + name +
"\" cannot be used to define a macro."); "\" cannot be used to define a macro.");
} }
Object *Object::makeInstance(const string &/*name*/, Statement &, const Parser *) { Object *Object::makeInstance(const std::string &/*name*/, Statement &, const Parser *) {
throw ParseError("Object::makeInstance()", "Object \"" + getOpalName() + throw ParseError("Object::makeInstance()", "Object \"" + getOpalName() +
"\" cannot be called as a macro."); "\" cannot be called as a macro.");
} }
...@@ -99,7 +96,7 @@ Object *Object::makeInstance(const string &/*name*/, Statement &, const Parser * ...@@ -99,7 +96,7 @@ Object *Object::makeInstance(const string &/*name*/, Statement &, const Parser *
void Object::parse(Statement &stat) { void Object::parse(Statement &stat) {
while(stat.delimiter(',')) { while(stat.delimiter(',')) {
string name = Expressions::parseString(stat, "Attribute name expected."); std::string name = Expressions::parseString(stat, "Attribute name expected.");
if(Attribute *attr = findAttribute(name)) { if(Attribute *attr = findAttribute(name)) {
if(stat.delimiter('[')) { if(stat.delimiter('[')) {
...@@ -133,7 +130,7 @@ void Object::parseShortcut(Statement &stat, bool eval) { ...@@ -133,7 +130,7 @@ void Object::parseShortcut(Statement &stat, bool eval) {
// Only one attribute. // Only one attribute.
if(stat.delimiter(',')) { if(stat.delimiter(',')) {
stat.mark(); stat.mark();
string name; std::string name;
if(stat.word(name)) { if(stat.word(name)) {
if(stat.delimiter('=')) { if(stat.delimiter('=')) {
...@@ -141,7 +138,7 @@ void Object::parseShortcut(Statement &stat, bool eval) { ...@@ -141,7 +138,7 @@ void Object::parseShortcut(Statement &stat, bool eval) {
attr->parse(stat, eval); attr->parse(stat, eval);
return; return;
} else { } else {
throw ParseError("Object::parse()", "Object \"" + getOpalName() + throw ParseError("Object::parseShortcut()", "Object \"" + getOpalName() +
"\" has no attribute \"" + name + "\"."); "\" has no attribute \"" + name + "\".");
} }
} else if(stat.delimiter(":=")) { } else if(stat.delimiter(":=")) {
...@@ -149,7 +146,7 @@ void Object::parseShortcut(Statement &stat, bool eval) { ...@@ -149,7 +146,7 @@ void Object::parseShortcut(Statement &stat, bool eval) {
attr->parse(stat, false); attr->parse(stat, false);
return; return;
} else { } else {
throw ParseError("Object::parse()", "Object \"" + getOpalName() + throw ParseError("Object::parseShortcut()", "Object \"" + getOpalName() +
"\" has no attribute \"" + name + "\"."); "\" has no attribute \"" + name + "\".");
} }
} }
...@@ -162,7 +159,7 @@ void Object::parseShortcut(Statement &stat, bool eval) { ...@@ -162,7 +159,7 @@ void Object::parseShortcut(Statement &stat, bool eval) {
void Object::print(std::ostream & msg) const { void Object::print(std::ostream & msg) const {
string head = getOpalName(); std::string head = getOpalName();
Object *parent = getParent(); Object *parent = getParent();
if(parent != 0 && ! parent->getOpalName().empty()) { if(parent != 0 && ! parent->getOpalName().empty()) {
if(! getOpalName().empty()) head += ':'; if(! getOpalName().empty()) head += ':';
...@@ -172,12 +169,12 @@ void Object::print(std::ostream & msg) const { ...@@ -172,12 +169,12 @@ void Object::print(std::ostream & msg) const {
msg << head; msg << head;
int pos = head.length(); int pos = head.length();
for(vector<Attribute>::const_iterator i = itsAttr.begin(); for(std::vector<Attribute>::const_iterator i = itsAttr.begin();
i != itsAttr.end(); ++i) { i != itsAttr.end(); ++i) {
if(*i) i->print(pos); if(*i) i->print(pos);
} }
msg << ';'; msg << ';';
msg << endl; msg << std::endl;
return; return;
} }
...@@ -208,17 +205,17 @@ void Object::printHelp(std::ostream &/*os*/) const { ...@@ -208,17 +205,17 @@ void Object::printHelp(std::ostream &/*os*/) const {
*gmsg << "Attributes:" << endl; *gmsg << "Attributes:" << endl;
size_t maxLength = 16; size_t maxLength = 16;
vector<Attribute>::const_iterator it; std::vector<Attribute>::const_iterator it;
for (it = itsAttr.begin(); it != itsAttr.end(); ++ it) { for (it = itsAttr.begin(); it != itsAttr.end(); ++ it) {
string name = it->getName(); std::string name = it->getName();
maxLength = std::max(maxLength, name.length() + 1); maxLength = std::max(maxLength, name.length() + 1);
} }
for (it = itsAttr.begin(); it != itsAttr.end(); ++ it) { for (it = itsAttr.begin(); it != itsAttr.end(); ++ it) {
string type = it->getType(); std::string type = it->getType();
string name = it->getName(); std::string name = it->getName();
*gmsg << '\t' << type << string(16 - type.length(), ' '); *gmsg << '\t' << type << std::string(16 - type.length(), ' ');
*gmsg << name << string(maxLength - name.length(), ' '); *gmsg << name << std::string(maxLength - name.length(), ' ');
*gmsg << it->getHelp(); *gmsg << it->getHelp();
if(it->isReadOnly()) *gmsg << " (read only)"; if(it->isReadOnly()) *gmsg << " (read only)";
*gmsg << endl; *gmsg << endl;
...@@ -281,7 +278,7 @@ const Object *Object::getBaseObject() const { ...@@ -281,7 +278,7 @@ const Object *Object::getBaseObject() const {
} }
const string &Object::getOpalName() const { const std::string &Object::getOpalName() const {
return itsName; return itsName;
} }
...@@ -302,7 +299,7 @@ bool Object::isTreeMember(const Object *classObject) const { ...@@ -302,7 +299,7 @@ bool Object::isTreeMember(const Object *classObject) const {
} }
void Object::setOpalName(const string &name) { void Object::setOpalName(const std::string &name) {
itsName = name; itsName = name;
} }
...@@ -339,7 +336,7 @@ Object::Object(int size, const char *name, const char *help): ...@@ -339,7 +336,7 @@ Object::Object(int size, const char *name, const char *help):
} }
Object::Object(const string &name, Object *parent): Object::Object(const std::string &name, Object *parent):
RCObject(), itsAttr(parent->itsAttr), itsParent(parent), RCObject(), itsAttr(parent->itsAttr), itsParent(parent),
itsName(name), itsHelp(parent->itsHelp), occurrence(0), sharedFlag(false) { itsName(name), itsHelp(parent->itsHelp), occurrence(0), sharedFlag(false) {
// The object is now different from the data base. // The object is now different from the data base.
......
...@@ -212,7 +212,7 @@ public: ...@@ -212,7 +212,7 @@ public:
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const; void registerOwnership(const AttributeHandler::OwnerType &itsClass) const;
/// The object attributes (see Attribute.hh). /// The object attributes.
std::vector<Attribute> itsAttr; std::vector<Attribute> itsAttr;
protected: protected:
......
...@@ -17,9 +17,12 @@ ...@@ -17,9 +17,12 @@
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
#include "BasicActions/Value.h" #include "BasicActions/Value.h"
#include "Attributes/Attributes.h" #include "Attributes/Attributes.h"
#include <iomanip> #include "Parser/Statement.h"
#include <iostream> #include "Utility/Inform.h"
#include <string>
#include <vector> #include <vector>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment