use own namespace
This commit is contained in:
@@ -19,9 +19,11 @@
|
||||
#include "contrib.h"
|
||||
#include "tem.h"
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
bool libebus_contrib_register() {
|
||||
contrib_tem_register();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* configure switch: --without-contrib
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
/**
|
||||
* Registration function that is called once during initialization.
|
||||
@@ -32,4 +32,6 @@ using namespace std;
|
||||
*/
|
||||
bool libebus_contrib_register();
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
#endif // LIB_EBUS_CONTRIB_CONTRIB_H_
|
||||
|
||||
@@ -29,7 +29,11 @@
|
||||
#include <cstring>
|
||||
#include "datatype.h"
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
using std::setfill;
|
||||
using std::setw;
|
||||
using std::dec;
|
||||
|
||||
void contrib_tem_register() {
|
||||
DataTypeList::getInstance()->add(new TemParamDataType("TEM_P"));
|
||||
@@ -135,3 +139,5 @@ result_t TemParamDataType::writeSymbols(istringstream& input,
|
||||
}
|
||||
return writeRawValue(value, offset, length, output, usedLength);
|
||||
}
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
* Contributed data types for TEM devices not part of regular releases.
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
/**
|
||||
* A special variant of @a NumberDataType for TEM/Dungs ParamID in master/slave
|
||||
@@ -68,4 +68,6 @@ class TemParamDataType : public NumberDataType {
|
||||
*/
|
||||
void contrib_tem_register();
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
#endif // LIB_EBUS_CONTRIB_TEM_H_
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "tem.h"
|
||||
#include "data.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ebusd;
|
||||
|
||||
static bool error = false;
|
||||
|
||||
|
||||
@@ -29,7 +29,11 @@
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
using std::dec;
|
||||
using std::hex;
|
||||
using std::setw;
|
||||
|
||||
/** the week day names. */
|
||||
static const char* dayNames[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
||||
@@ -1057,3 +1061,5 @@ DataField* DataFieldTemplates::get(const string name) {
|
||||
}
|
||||
return ref->second;
|
||||
}
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
+4
-1
@@ -45,7 +45,8 @@
|
||||
* instances from configuration files by inheriting the @a FileReader template
|
||||
* class.
|
||||
*/
|
||||
using namespace std;
|
||||
|
||||
namespace ebusd {
|
||||
|
||||
class DataFieldTemplates;
|
||||
class SingleDataField;
|
||||
@@ -656,4 +657,6 @@ class DataFieldTemplates : public FileReader {
|
||||
map<string, DataField*> m_fieldsByName;
|
||||
};
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
#endif // LIB_EBUS_DATA_H_
|
||||
|
||||
@@ -31,7 +31,14 @@
|
||||
# include "contrib/contrib.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
using std::dec;
|
||||
using std::hex;
|
||||
using std::fixed;
|
||||
using std::setfill;
|
||||
using std::setprecision;
|
||||
using std::setw;
|
||||
|
||||
unsigned int parseInt(const char* str, int base, const unsigned int minValue, const unsigned int maxValue, result_t& result, unsigned int* length) {
|
||||
char* strEnd = NULL;
|
||||
@@ -1073,3 +1080,5 @@ DataType* DataTypeList::get(const string id, const unsigned char length) {
|
||||
}
|
||||
return dataType;
|
||||
}
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
@@ -46,7 +46,10 @@
|
||||
* an @a istringstream to a @a SymbolString (see @a DataType#writeSymbols()).
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
using std::map;
|
||||
using std::list;
|
||||
|
||||
/** the separator character used between base type name and length (in CSV only). */
|
||||
#define LENGTH_SEPARATOR ':'
|
||||
@@ -584,4 +587,6 @@ class DataTypeList {
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
#endif // LIB_EBUS_DATATYPE_H_
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <fstream>
|
||||
#include "data.h"
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
Device::~Device() {
|
||||
close();
|
||||
@@ -323,3 +323,5 @@ ssize_t NetworkDevice::read(unsigned char& value) {
|
||||
}
|
||||
return Device::read(value);
|
||||
}
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
* to a file and/or forwarding it to a logging function.
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
/**
|
||||
* Interface for listening to data received on/sent to a device.
|
||||
@@ -284,4 +284,6 @@ class NetworkDevice : public Device {
|
||||
unsigned char m_bufPos;
|
||||
};
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
#endif // LIB_EBUS_DEVICE_H_
|
||||
|
||||
@@ -39,7 +39,16 @@
|
||||
* with a "*" symbol.
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
using std::string;
|
||||
using std::ostream;
|
||||
using std::ostringstream;
|
||||
using std::istream;
|
||||
using std::istringstream;
|
||||
using std::ifstream;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
/** the separator character used between fields. */
|
||||
#define FIELD_SEPARATOR ','
|
||||
@@ -376,4 +385,6 @@ class FileReader {
|
||||
string m_lastError;
|
||||
};
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
#endif // LIB_EBUS_FILEREADER_H_
|
||||
|
||||
@@ -27,7 +27,13 @@
|
||||
#include "result.h"
|
||||
#include "symbol.h"
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
using std::dec;
|
||||
using std::hex;
|
||||
using std::nouppercase;
|
||||
using std::setfill;
|
||||
using std::setw;
|
||||
|
||||
/** the maximum length of the command ID bytes (in addition to PB/SB) for which the key is distinct. */
|
||||
#define MAX_ID_KEYLEN 4
|
||||
@@ -2197,3 +2203,5 @@ void MessageMap::dump(ostream& output, bool withConditions) {
|
||||
output << endl;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
@@ -56,7 +56,11 @@
|
||||
* template class.
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
using std::binary_function;
|
||||
using std::priority_queue;
|
||||
using std::deque;
|
||||
|
||||
class Condition;
|
||||
class SimpleCondition;
|
||||
@@ -702,7 +706,7 @@ class ChainedMessage : public Message {
|
||||
/**
|
||||
* A function that compares the weighted poll priority of two @a Message instances.
|
||||
*/
|
||||
struct compareMessagePriority : binary_function <Message*, Message*, bool> {
|
||||
struct compareMessagePriority : binary_function<Message*, Message*, bool> {
|
||||
/**
|
||||
* Compare the weighted poll priority of the two @a Message instances.
|
||||
* @param x the first @a Message.
|
||||
@@ -1377,4 +1381,6 @@ class MessageMap : public FileReader {
|
||||
map<string, vector<Instruction*> > m_instructions;
|
||||
};
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
#endif // LIB_EBUS_MESSAGE_H_
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "result.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
const char* getResultCode(result_t resultCode) {
|
||||
switch (resultCode) {
|
||||
@@ -58,3 +58,4 @@ const char* getResultCode(result_t resultCode) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
* whereas negative values indicate failure.
|
||||
*/
|
||||
|
||||
namespace ebusd {
|
||||
|
||||
/** type for result code. */
|
||||
enum result_t {
|
||||
RESULT_OK = 0, //!< success
|
||||
@@ -70,4 +72,6 @@ enum result_t {
|
||||
*/
|
||||
const char* getResultCode(result_t resultCode);
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
#endif // LIB_EBUS_RESULT_H_
|
||||
|
||||
@@ -23,7 +23,13 @@
|
||||
#include <vector>
|
||||
#include "result.h"
|
||||
|
||||
using namespace std;
|
||||
namespace ebusd {
|
||||
|
||||
using std::ostringstream;
|
||||
using std::nouppercase;
|
||||
using std::setw;
|
||||
using std::hex;
|
||||
using std::setfill;
|
||||
|
||||
/**
|
||||
* CRC8 lookup table for the polynom 0x9b = x^8 + x^7 + x^4 + x^3 + x^1 + 1.
|
||||
@@ -83,7 +89,7 @@ result_t SymbolString::parseHex(const string& str, const bool isEscaped) {
|
||||
}
|
||||
|
||||
const string SymbolString::getDataStr(const bool unescape, const bool skipLastSymbol) {
|
||||
stringstream sstr;
|
||||
ostringstream sstr;
|
||||
bool previousEscape = false;
|
||||
|
||||
for (size_t i = 0; i < m_data.size(); i++) {
|
||||
@@ -255,3 +261,4 @@ bool isValidAddress(unsigned char addr, bool allowBroadcast) {
|
||||
return addr != SYN && addr != ESC && (allowBroadcast || addr != BROADCAST);
|
||||
}
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#include <vector>
|
||||
#include "result.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/** @file symbol.h
|
||||
* Classes, functions, and constants related to symbols on the eBUS.
|
||||
*
|
||||
@@ -65,6 +63,11 @@ using namespace std;
|
||||
* non-acknowledge, the receiving slave has to repeat its data once.
|
||||
*/
|
||||
|
||||
namespace ebusd {
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
static const unsigned char ESC = 0xA9; //!< escape symbol, either followed by 0x00 for the value 0xA9, or 0x01 for the value 0xAA
|
||||
static const unsigned char SYN = 0xAA; //!< synchronization symbol
|
||||
static const unsigned char ACK = 0x00; //!< positive acknowledge
|
||||
@@ -257,4 +260,6 @@ unsigned char getMasterNumber(unsigned char addr);
|
||||
*/
|
||||
bool isValidAddress(unsigned char addr, bool allowBroadcast = true);
|
||||
|
||||
} // namespace ebusd
|
||||
|
||||
#endif // LIB_EBUS_SYMBOL_H_
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <vector>
|
||||
#include "data.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ebusd;
|
||||
|
||||
static bool error = false;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <iomanip>
|
||||
#include "device.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ebusd;
|
||||
|
||||
int main() {
|
||||
Device* device = Device::create("/dev/ttyUSB20", true, false, false);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "filereader.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ebusd;
|
||||
|
||||
static bool error = false;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <map>
|
||||
#include "message.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ebusd;
|
||||
|
||||
void verify(bool expectFailMatch, string type, string input,
|
||||
bool match, string expectStr, string gotStr) {
|
||||
@@ -45,12 +45,14 @@ void verify(bool expectFailMatch, string type, string input,
|
||||
|
||||
DataFieldTemplates* templates = NULL;
|
||||
|
||||
namespace ebusd {
|
||||
DataFieldTemplates* getTemplates(const string filename) {
|
||||
if (filename == "") { // avoid compiler warning
|
||||
return templates;
|
||||
}
|
||||
return templates;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
// message: [type],[circuit],name,[comment],[QQ[;QQ]*],[ZZ],[PBSB],[ID],fields...
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <string>
|
||||
#include "symbol.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ebusd;
|
||||
|
||||
static bool error = false;
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include <string.h>
|
||||
#include "clock.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/** the name of each @a LogFacility. */
|
||||
static const char *facilityNames[] = {
|
||||
"main",
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/** \file queue.h */
|
||||
|
||||
using namespace std;
|
||||
using std::list;
|
||||
|
||||
/**
|
||||
* Thread safe template class for queuing items.
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <string>
|
||||
#include "clock.h"
|
||||
|
||||
using namespace std;
|
||||
using std::streamsize;
|
||||
|
||||
RotateFile::~RotateFile() {
|
||||
if (m_stream) {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* Helpers for writing to rotating files.
|
||||
*/
|
||||
|
||||
using namespace std;
|
||||
using std::string;
|
||||
|
||||
/**
|
||||
* Helper class for writing to a rotating file with maximum size.
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#include <string.h>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std;
|
||||
|
||||
TCPSocket::TCPSocket(int sfd, struct sockaddr_in* address) : m_sfd(sfd) {
|
||||
char ip[17];
|
||||
inet_ntop(AF_INET, (struct in_addr*)&(address->sin_addr.s_addr), ip, (socklen_t)sizeof(ip)-1);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/** \file tcpsocket.h */
|
||||
|
||||
using namespace std;
|
||||
using std::string;
|
||||
|
||||
#ifdef __MACH__
|
||||
#ifndef MSG_NOSIGNAL
|
||||
|
||||
Reference in New Issue
Block a user