HCE project C++ developers source code library  1.1.1
HCE project developer library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CustomMessage.cpp
Go to the documentation of this file.
1 #include <sstream>
2 
3 #include "CustomMessage.hpp"
4 
5 namespace HCE
6 {
7 //-----------------------------------------------------------------------------
9 : msgConst(), collection(collection_)
10 {
11 }
12 //-----------------------------------------------------------------------------
14 {
15 }
16 //-----------------------------------------------------------------------------
17 void CustomMessage::setMsgConst(const MsgConst& msgConst_)
18 {
19  msgConst.space = msgConst_.space;
20  msgConst.point = msgConst_.point;
21  msgConst.delimiter = msgConst_.delimiter;
22 }
23 //-----------------------------------------------------------------------------
24 std::string CustomMessage::makeMessage(unsigned int type)
25 {
26  std::ostringstream outMsg;
27  outMsg << collection.getMessage(type) << msgConst.point << msgConst.space;
28  return outMsg.str();
29 }
30 //-----------------------------------------------------------------------------
31 std::string CustomMessage::makeMessage(unsigned int type, const std::string& arg)
32 {
33  std::ostringstream outMsg;
34  outMsg << collection.getMessage(type);
35  if (!outMsg.str().empty() && !arg.empty())
36  outMsg << msgConst.delimiter << msgConst.space << arg << msgConst.space;
37  return outMsg.str();
38 }
39 //-----------------------------------------------------------------------------
40 std::string CustomMessage::operator()(unsigned int type)
41 {
42  return makeMessage(type);
43 }
44 //-----------------------------------------------------------------------------
45 std::string CustomMessage::operator()(unsigned int type, const std::string& arg)
46 {
47  return makeMessage(type, arg);
48 }
49 //-----------------------------------------------------------------------------
50 std::string CustomMessage::operator()(unsigned int type, const char* arg)
51 {
52  return makeMessage(type, ((arg)?std::string(arg):std::string()));
53 }
54 //-----------------------------------------------------------------------------
55 std::string CustomMessage::operator()(unsigned int type, unsigned int arg)
56 {
57  return makeMessage(type, std::to_string(arg));
58 }
59 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
61 
62 } // end namespace HCE