Permalink
Browse files

Removed the last remnants of using namespace std;

  • Loading branch information...
1 parent 2cf8bb7 commit 6a61083a0aa45e178279796bf7c80c2f480d27ce Yohann Ferreira committed Sep 5, 2012
@@ -19,12 +19,9 @@
#include "engine/script/script.h"
#include "engine/video/video.h"
-using namespace std;
-
using namespace hoa_utils;
using namespace hoa_script;
using namespace hoa_video;
-
using namespace hoa_global::private_global;
namespace hoa_global {
@@ -37,7 +34,7 @@ void GlobalObject::_LoadObjectData(hoa_script::ReadScriptDescriptor& script) {
_name = MakeUnicodeString(script.ReadString("name"));
_description = MakeUnicodeString(script.ReadString("description"));
_price = script.ReadUInt("standard_price");
- string icon_file = script.ReadString("icon");
+ std::string icon_file = script.ReadString("icon");
if (_icon_image.Load(icon_file) == false) {
IF_PRINT_WARNING(GLOBAL_DEBUG) << "failed to load icon image for item: " << _id << std::endl;
_InvalidateObject();
@@ -81,8 +78,8 @@ GlobalItem::GlobalItem(uint32 id, uint32 count) :
script_file.CloseTable();
if (script_file.IsErrorDetected()) {
if (GLOBAL_DEBUG) {
- PRINT_WARNING << "one or more errors occurred while reading item data - they are listed below" << std::endl;
- cerr << script_file.GetErrorMessages() << std::endl;
+ PRINT_WARNING << "one or more errors occurred while reading item data - they are listed below"
+ << std::endl << script_file.GetErrorMessages() << std::endl;
}
_InvalidateObject();
}
@@ -127,14 +124,14 @@ GlobalWeapon::GlobalWeapon(uint32 id, uint32 count) :
_has_ammo(false)
{
// Initialize all elemental effects as neutral
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_FIRE, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_WATER, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_VOLT, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_EARTH, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SLICING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SMASHING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_MAULING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_PIERCING, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_FIRE, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_WATER, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_VOLT, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_EARTH, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SLICING, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SMASHING, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_MAULING, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_PIERCING, GLOBAL_INTENSITY_NEUTRAL));
if ((_id <= MAX_ITEM_ID) || (_id > MAX_WEAPON_ID)) {
IF_PRINT_WARNING(GLOBAL_DEBUG) << "invalid id in constructor: " << _id << std::endl;
@@ -165,8 +162,8 @@ GlobalWeapon::GlobalWeapon(uint32 id, uint32 count) :
script_file.CloseTable();
if (script_file.IsErrorDetected()) {
if (GLOBAL_DEBUG) {
- PRINT_WARNING << "one or more errors occurred while reading weapon data - they are listed below" << std::endl;
- cerr << script_file.GetErrorMessages() << std::endl;
+ PRINT_WARNING << "one or more errors occurred while reading weapon data - they are listed below"
+ << std::endl << script_file.GetErrorMessages() << std::endl;
}
_InvalidateObject();
}
@@ -180,14 +177,14 @@ GlobalArmor::GlobalArmor(uint32 id, uint32 count) :
GlobalObject(id, count)
{
// Initialize all elemental effects as neutral
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_FIRE, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_WATER, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_VOLT, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_EARTH, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SLICING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SMASHING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_MAULING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_PIERCING, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_FIRE, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_WATER, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_VOLT, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_EARTH, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SLICING, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SMASHING, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_MAULING, GLOBAL_INTENSITY_NEUTRAL));
+ _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_PIERCING, GLOBAL_INTENSITY_NEUTRAL));
if ((_id <= MAX_WEAPON_ID) || (_id > MAX_LEG_ARMOR_ID)) {
IF_PRINT_WARNING(GLOBAL_DEBUG) << "invalid id in constructor: " << _id << std::endl;
@@ -233,8 +230,8 @@ GlobalArmor::GlobalArmor(uint32 id, uint32 count) :
script_file->CloseTable();
if (script_file->IsErrorDetected()) {
if (GLOBAL_DEBUG) {
- PRINT_WARNING << "one or more errors occurred while reading armor data - they are listed below" << std::endl;
- cerr << script_file->GetErrorMessages() << std::endl;
+ PRINT_WARNING << "one or more errors occurred while reading armor data - they are listed below"
+ << std::endl << script_file->GetErrorMessages() << std::endl;
}
_InvalidateObject();
}
@@ -317,8 +314,8 @@ GlobalKeyItem::GlobalKeyItem(uint32 id, uint32 count) :
script_file.CloseTable();
if (script_file.IsErrorDetected()) {
if (GLOBAL_DEBUG) {
- PRINT_WARNING << "one or more errors occurred while reading key item data - they are listed below" << std::endl;
- cerr << script_file.GetErrorMessages() << std::endl;
+ PRINT_WARNING << "one or more errors occurred while reading key item data - they are listed below"
+ << std::endl << script_file.GetErrorMessages() << std::endl;
}
_InvalidateObject();
}
View
@@ -28,7 +28,6 @@
using namespace hoa_script;
using namespace hoa_map::private_map;
using namespace hoa_video;
-using namespace std;
namespace hoa_editor {
@@ -169,7 +168,7 @@ bool Grid::CreateNewContext(std::string name, int32 inherit_context)
return false;
int context_id = _tile_contexts.size();
- stringstream context;
+ std::stringstream context;
context << "context_";
if (context_id < 10)
context << "0";
@@ -217,21 +216,21 @@ bool Grid::LoadMap()
// File descriptor for the map data that is to be read
ReadScriptDescriptor read_data;
// Used to read in vectors from the file
- vector<int32> vect;
+ std::vector<int32> vect;
// Used as the window title for any errors that are detected and to notify
// the user via a message box
QString message_box_title("Load File Error");
// Open the map file for reading
- if (read_data.OpenFile(string(_file_name.toAscii()), true) == false)
+ if (read_data.OpenFile(std::string(_file_name.toAscii()), true) == false)
{
QMessageBox::warning(this, message_box_title,
QString("Could not open file %1 for reading.").arg(_file_name));
return false;
}
// Check that the main table containing the map exists and open it
- string main_map_table = string(_file_name.section('/', -1).
+ std::string main_map_table = std::string(_file_name.section('/', -1).
remove(".lua").toAscii());
if (read_data.DoesTableExist(main_map_table) == false)
{
@@ -475,9 +474,9 @@ bool Grid::LoadMap()
// which tile image should be used for this context. So if the first
// four entries in the context table were {0, 12, 26, 180}, this would
// set the lower layer tile at position (12, 26) to the tile index 180.
- vector<int32> context_data;
+ std::vector<int32> context_data;
- stringstream context;
+ std::stringstream context;
context << "context_";
if (ctxt < 10)
context << "0";
@@ -518,7 +517,7 @@ void Grid::GetScriptingData()
char buffer[BUFFER_SIZE];
// First, get the non-editor data (such as map scripting) from the file to save, so we don't clobber it.
- file.open(_file_name.toAscii(), ifstream::in);
+ file.open(_file_name.toAscii(), std::ifstream::in);
if (file.is_open()) {
// Search for AFTER_TEXT_MARKER
while (!file.eof()) {
@@ -547,15 +546,15 @@ void Grid::SaveMap()
{
WriteScriptDescriptor write_data;
- if (write_data.OpenFile(string(_file_name.toAscii())) == false) {
+ if (write_data.OpenFile(std::string(_file_name.toAscii())) == false) {
QMessageBox::warning(this, "Saving File...", QString("ERROR: could not open %1 for writing!").arg(_file_name));
return;
}
write_data.WriteLine(BEFORE_TEXT_MARKER);
write_data.InsertNewLine();
write_data.WriteComment("Set the namespace according to the map name.");
- string main_map_table = string(_file_name.section('/', -1).remove(".lua").toAscii());
+ std::string main_map_table = std::string(_file_name.section('/', -1).remove(".lua").toAscii());
write_data.WriteNamespace(main_map_table);
write_data.InsertNewLine();
@@ -758,7 +757,7 @@ void Grid::SaveMap()
if (_tile_contexts.size() > 1)
write_data.WriteComment("Contexts data");
- vector<int32> context_data; // one vector of ints contains all the context info
+ std::vector<int32> context_data; // one vector of ints contains all the context info
// Iterate through all contexts of all layers.
for (uint32 context_id = 1; context_id < _tile_contexts.size(); ++context_id)
{
@@ -796,7 +795,7 @@ void Grid::SaveMap()
if (!context_data.empty())
{
- stringstream context;
+ std::stringstream context;
context << "context_";
if (context_id < 10)
context << "0";
@@ -1089,7 +1088,7 @@ void Grid::paintGL()
{
int32 x, y; // tile array loop index
int layer_index;
- vector<int32>::iterator it; // used to iterate through tile arrays
+ std::vector<int32>::iterator it; // used to iterate through tile arrays
int tileset_index; // index into the tileset_names vector
int tile_index; // ranges from 0-255
int left_tile;
@@ -26,7 +26,7 @@
#include <boost/preprocessor/cat.hpp>
#include <luabind/error.hpp>
-extern "C"
+extern "C"
{
#include "lua.h"
#include "lauxlib.h"
@@ -74,7 +74,7 @@ template<class T>
struct counted_type
{
static int count;
-
+
counted_type()
{
++count;
@@ -102,7 +102,6 @@ int counted_type<T>::count = 0;
} \
catch (luabind::error const& e) \
{ \
- using namespace std; \
if (std::strcmp( \
lua_tostring(e.state(), -1) \
, (char const*)expected)) \
View
@@ -46,7 +46,6 @@
#include <SDL_image.h>
#include <time.h>
-using namespace std;
using namespace hoa_utils;
using namespace hoa_audio;
using namespace hoa_video;
@@ -119,9 +118,9 @@ bool LoadSettings()
settings.CloseTable();
if (settings.IsErrorDetected()) {
- cerr << "SETTINGS LOAD ERROR: failure while trying to retrieve key map "
- << "information from file: " << GetSettingsFilename() << std::endl;
- cerr << settings.GetErrorMessages() << std::endl;
+ PRINT_ERROR << "SETTINGS LOAD ERROR: failure while trying to retrieve key map "
+ << "information from file: " << GetSettingsFilename() << std::endl
+ << settings.GetErrorMessages() << std::endl;
return false;
}
@@ -167,9 +166,9 @@ bool LoadSettings()
}
if (settings.IsErrorDetected()) {
- cerr << "SETTINGS LOAD ERROR: an error occured while trying to retrieve joystick mapping information "
- << "from file: " << GetSettingsFilename() << std::endl;
- cerr << settings.GetErrorMessages() << std::endl;
+ PRINT_ERROR << "SETTINGS LOAD ERROR: an error occured while trying to retrieve joystick mapping information "
+ << "from file: " << GetSettingsFilename() << std::endl
+ << settings.GetErrorMessages() << std::endl;
return false;
}
@@ -183,9 +182,9 @@ bool LoadSettings()
settings.CloseTable();
if (settings.IsErrorDetected()) {
- cerr << "SETTINGS LOAD ERROR: failure while trying to retrieve video settings "
- << "information from file: " << GetSettingsFilename() << std::endl;
- cerr << settings.GetErrorMessages() << std::endl;
+ PRINT_ERROR << "SETTINGS LOAD ERROR: failure while trying to retrieve video settings "
+ << "information from file: " << GetSettingsFilename() << std::endl
+ << settings.GetErrorMessages() << std::endl;
return false;
}
@@ -198,9 +197,9 @@ bool LoadSettings()
settings.CloseAllTables();
if (settings.IsErrorDetected()) {
- cerr << "SETTINGS LOAD ERROR: failure while trying to retrieve audio settings "
- << "information from file: " << GetSettingsFilename() << std::endl;
- cerr << settings.GetErrorMessages() << std::endl;
+ PRINT_ERROR << "SETTINGS LOAD ERROR: failure while trying to retrieve audio settings "
+ << "information from file: " << GetSettingsFilename() << std::endl
+ << settings.GetErrorMessages() << std::endl;
return false;
}
@@ -360,7 +359,7 @@ int main(int argc, char *argv[]) {
chdir(path.c_str());
#elif (defined(__linux__) || defined(__FreeBSD__)) && !defined(RELEASE_BUILD)
// Look for data files in DATADIR only if they are not available in the current directory.
- if (ifstream("dat/config/settings.lua") == NULL) {
+ if (std::ifstream("dat/config/settings.lua") == NULL) {
if (chdir(PKG_DATADIR) != 0) {
throw Exception("ERROR: failed to change directory to data location", __FILE__, __LINE__, __FUNCTION__);
}
@@ -381,11 +380,11 @@ int main(int argc, char *argv[]) {
// Function call below throws exceptions if any errors occur
InitializeEngine();
- } catch (Exception& e) {
+ } catch (const Exception& e) {
#ifdef WIN32
MessageBox(NULL, e.ToString().c_str(), "Unhandled exception", MB_OK | MB_ICONERROR);
#else
- cerr << e.ToString() << std::endl;
+ std::cerr << e.ToString() << std::endl;
#endif
return EXIT_FAILURE;
}
@@ -423,11 +422,11 @@ int main(int argc, char *argv[]) {
ModeManager->Update();
} // while (SystemManager->NotDone())
- } catch (Exception& e) {
+ } catch (const Exception& e) {
#ifdef WIN32
MessageBox(NULL, e.ToString().c_str(), "Unhandled exception", MB_OK | MB_ICONERROR);
#else
- cerr << e.ToString() << std::endl;
+ std::cerr << e.ToString() << std::endl;
#endif
return EXIT_FAILURE;
}
Oops, something went wrong.

0 comments on commit 6a61083

Please sign in to comment.