From d9b07638b630851c30cc8d6c882b31d66ac637e3 Mon Sep 17 00:00:00 2001 From: paulc Date: Tue, 8 Jun 2010 15:25:05 +0000 Subject: [PATCH] Made a lot of constructors explicit to prevent undesirable automatic conversions. Fixed two undesirable automatic conversions exposed by this change. git-svn-id: http://voip.null.ro/svn/yate@3366 acf43c95-373e-0410-b603-e72c3f656dc1 --- engine/Client.cpp | 2 +- modules/server/sipfeatures.cpp | 2 +- yatecbase.h | 18 +++++++++--------- yateclass.h | 30 +++++++++++++++--------------- yatemime.h | 2 +- yatengine.h | 12 ++++++------ yatephone.h | 18 +++++++++--------- 7 files changed, 42 insertions(+), 42 deletions(-) diff --git a/engine/Client.cpp b/engine/Client.cpp index de319158..b0ad61f8 100644 --- a/engine/Client.cpp +++ b/engine/Client.cpp @@ -174,7 +174,7 @@ Configuration Client::s_providers; // Provider settings Configuration Client::s_history; // Call log Configuration Client::s_calltoHistory; // Dialed destinations history int Client::s_changing = 0; -Regexp Client::s_notSelected = "^-\\(.*\\)-$"; // Holds a not selected/set value match +Regexp Client::s_notSelected("^-\\(.*\\)-$"); // Holds a not selected/set value match ObjList Client::s_logics; String Client::s_skinPath; // Skin path String Client::s_soundPath; // Sounds path diff --git a/modules/server/sipfeatures.cpp b/modules/server/sipfeatures.cpp index 1440e893..fa9ed0b6 100644 --- a/modules/server/sipfeatures.cpp +++ b/modules/server/sipfeatures.cpp @@ -196,7 +196,7 @@ bool YSipSubscribeHandler::received(Message &msg) notifyTo = notifyTo.matchString(1); m.addParam("notifyto",notifyTo); - URI uriRequest = msg.getValue("sip_uri"); + URI uriRequest(msg.getValue("sip_uri")); m.addParam("notifier",uriRequest.getUser()); // Pack data parameters String data; diff --git a/yatecbase.h b/yatecbase.h index f0dc20c1..206baa61 100644 --- a/yatecbase.h +++ b/yatecbase.h @@ -65,7 +65,7 @@ public: * Constructor, creates a new windows with an ID * @param id String identifier of the new window */ - Window(const char* id = 0); + explicit Window(const char* id = 0); /** * Destructor @@ -538,7 +538,7 @@ public: * Constructor, creates a new widget * @param name The widget's name */ - inline UIWidget(const char* name = 0) + inline explicit UIWidget(const char* name = 0) : String(name) {} @@ -703,7 +703,7 @@ public: /** * Constructor. Append itself to the factories list */ - UIFactory(const char* name); + explicit UIFactory(const char* name); /** * Destructor. Remove itself from list @@ -799,7 +799,7 @@ public: * Constructor * @param name The client's name */ - Client(const char *name = 0); + explicit Client(const char *name = 0); /** * Destructor @@ -1643,7 +1643,7 @@ public: * Constructor for utility channels used to play notifications * @param soundId The id of the sound to play */ - ClientChannel(const String& soundId); + explicit ClientChannel(const String& soundId); virtual ~ClientChannel(); @@ -2548,7 +2548,7 @@ public: * @param name The name of this logic * @param prio The priority of this logic */ - DefaultLogic(const char* name = "default", int prio = -100); + explicit DefaultLogic(const char* name = "default", int prio = -100); /** * Destructor @@ -2998,7 +2998,7 @@ public: * The list's name will be used as account id * @param contact Optional account's own contact */ - ClientAccount(const NamedList& params, ClientContact* contact = 0); + explicit ClientAccount(const NamedList& params, ClientContact* contact = 0); /** * Get this account's parameters @@ -3183,7 +3183,7 @@ public: * @param name List's name used for debug purposes * @param localContacts Optional account owning locally stored contacts */ - inline ClientAccountList(const char* name, ClientAccount* localContacts = 0) + inline explicit ClientAccountList(const char* name, ClientAccount* localContacts = 0) : String(name), Mutex(true,"ClientAccountList"), m_localContacts(localContacts) {} @@ -3628,7 +3628,7 @@ public: * @param name Optional display name. Defaults to the id's value if 0 * @param audio True (default) if the resource has audio capability */ - inline ClientResource(const char* id, const char* name = 0, bool audio = true) + inline explicit ClientResource(const char* id, const char* name = 0, bool audio = true) : m_id(id), m_name(name ? name : id), m_audio(audio), m_priority(0), m_status(Offline) {} diff --git a/yateclass.h b/yateclass.h index 872b34e9..6b43052d 100644 --- a/yateclass.h +++ b/yateclass.h @@ -505,7 +505,7 @@ public: * @param name Name of the function or block entered, must be static * @param format printf() style format string */ - Debugger(const char* name, const char* format = 0, ...); + explicit Debugger(const char* name, const char* format = 0, ...); /** * The constructor prints the method entry message and indents. @@ -1228,7 +1228,7 @@ public: * @param columns Initial number of columns * @param rows Initial number of rows */ - Array(int columns = 0, int rows = 0); + explicit Array(int columns = 0, int rows = 0); /** * Destructor. Destructs all objects in the array @@ -2120,7 +2120,7 @@ public: * @param extended True to use POSIX Extended Regular Expression syntax * @param insensitive True to not differentiate case */ - Regexp(const char* value, bool extended = false, bool insensitive = false); + explicit Regexp(const char* value, bool extended = false, bool insensitive = false); /** * Copy constructor. @@ -2204,7 +2204,7 @@ public: * @param name Name of this string * @param value Initial value of the string */ - NamedString(const char* name, const char* value = 0); + explicit NamedString(const char* name, const char* value = 0); /** * Retrive the name of this string. @@ -2252,7 +2252,7 @@ public: * @param data Initial pointer value. The pointer will be owned by this object * @param value Initial string value */ - NamedPointer(const char* name, GenObject* data = 0, const char* value = 0); + explicit NamedPointer(const char* name, GenObject* data = 0, const char* value = 0); /** * Destructor. Release the pointer @@ -2326,7 +2326,7 @@ public: * Creates a new, empty list. * @param size Number of classes to divide the objects */ - HashList(unsigned int size = 17); + explicit HashList(unsigned int size = 17); /** * Destroys the list and everything in it. @@ -3232,7 +3232,7 @@ public: * Creates a new named list. * @param name Name of the list - must not be NULL or empty */ - NamedList(const char* name); + explicit NamedList(const char* name); /** * Copy constructor @@ -3499,13 +3499,13 @@ public: * Constructor from a String that gets parsed later * @param uri String form of the URI */ - URI(const String& uri); + explicit URI(const String& uri); /** * Constructor from a C string that gets parsed later * @param uri String form of the URI */ - URI(const char* uri); + explicit URI(const char* uri); /** * Constructor from URI components @@ -4213,7 +4213,7 @@ public: * false for a normal fast mutex * @param name Static name of the mutex (for debugging purpose only) */ - Mutex(bool recursive = false, const char* name = 0); + explicit Mutex(bool recursive = false, const char* name = 0); /** * Copy constructor, creates a shared mutex @@ -4300,7 +4300,7 @@ public: * @param maxcount Maximum unlock count, must be strictly positive * @param name Static name of the semaphore (for debugging purpose only) */ - Semaphore(unsigned int maxcount = 1, const char* name = 0); + explicit Semaphore(unsigned int maxcount = 1, const char* name = 0); /** * Copy constructor, creates a shared semaphore @@ -4793,7 +4793,7 @@ public: * Constructor of a null address * @param family Family of the address to create */ - SocketAddr(int family); + explicit SocketAddr(int family); /** * Constructor that stores a copy of an address @@ -5253,7 +5253,7 @@ public: * Constructor from an existing handle * @param handle Operating system handle to an open file */ - File(HANDLE handle); + explicit File(HANDLE handle); /** * Destructor, closes the file @@ -5497,7 +5497,7 @@ public: * Constructor from an existing handle * @param handle Operating system handle to an existing socket */ - Socket(SOCKET handle); + explicit Socket(SOCKET handle); /** * Constructor that also creates the socket handle @@ -5914,7 +5914,7 @@ public: * Constructor * @param fd File descriptor of an existing handle */ - inline SctpSocket(SOCKET fd) + inline explicit SctpSocket(SOCKET fd) : Socket(fd) { } diff --git a/yatemime.h b/yatemime.h index a0d2ff59..4722c5ae 100644 --- a/yatemime.h +++ b/yatemime.h @@ -432,7 +432,7 @@ public: * A random one will be created if missing. The length will be truncated * to 70 if this value is exceeded */ - MimeMultipartBody(const char* subtype = "mixed", const char* boundary = 0); + explicit MimeMultipartBody(const char* subtype = "mixed", const char* boundary = 0); /** * Constructor from block of data diff --git a/yatengine.h b/yatengine.h index 83761370..3d5a6fe7 100644 --- a/yatengine.h +++ b/yatengine.h @@ -30,7 +30,7 @@ #endif #include - + /** * Holds all Telephony Engine related classes. */ @@ -53,7 +53,7 @@ public: * @param filename Name of file to initialize from * @param warn True to warn if the configuration could not be loaded */ - Configuration(const char* filename, bool warn = true); + explicit Configuration(const char* filename, bool warn = true); /** * Assignment from string operator @@ -226,7 +226,7 @@ public: * @param name Name of the message - must not be NULL or empty * @param retval Default return value */ - Message(const char* name, const char* retval = 0); + explicit Message(const char* name, const char* retval = 0); /** * Copy constructor. @@ -385,7 +385,7 @@ public: * @param name Name of the handled message - may be NULL * @param priority Priority of the handler, 0 = top */ - MessageHandler(const char* name, unsigned priority = 100); + explicit MessageHandler(const char* name, unsigned priority = 100); /** * Handler destructor. @@ -437,7 +437,7 @@ public: */ void clearFilter(); -protected: +protected: /** * Remove the handler from its dispatcher, remove any installed filter. * This method is called internally from destruct and the destructor @@ -663,7 +663,7 @@ public: * @param name the undecorated name of the library that contains the plugin * @param earlyInit True to initialize the plugin early */ - Plugin(const char* name, bool earlyInit = false); + explicit Plugin(const char* name, bool earlyInit = false); /** * Creates a new Plugin container. diff --git a/yatephone.h b/yatephone.h index 8f317d92..b84eae76 100644 --- a/yatephone.h +++ b/yatephone.h @@ -121,7 +121,7 @@ struct YATE_API FormatInfo { /** * Normal constructor */ - inline FormatInfo(const char* _name, int fsize = 0, int ftime = 10000, + inline explicit FormatInfo(const char* _name, int fsize = 0, int ftime = 10000, const char* _type = "audio", int srate = 8000, int nchan = 1, bool convert = false) : name(_name), type(_type), frameSize(fsize), frameTime(ftime), @@ -236,7 +236,7 @@ public: * Constructor from format information * @param format Pointer to existing FormatInfo */ - inline DataFormat(const FormatInfo* format) + inline explicit DataFormat(const FormatInfo* format) : NamedList(format ? format->name : (const char*)0), m_parsed(format) { } @@ -320,7 +320,7 @@ public: * Construct a DataNode * @param format Description of the data format, default none */ - inline DataNode(const char* format = 0) + inline explicit DataNode(const char* format = 0) : m_format(format), m_timestamp(0) { } @@ -406,7 +406,7 @@ public: * Consumer constructor * @param format Name of the data format, default "slin" (Signed Linear) */ - inline DataConsumer(const char* format = "slin") + inline explicit DataConsumer(const char* format = "slin") : DataNode(format), m_source(0), m_override(0), m_regularTsDelta(0), m_overrideTsDelta(0), m_lastTsTime(0) @@ -486,7 +486,7 @@ public: * Source constructor * @param format Name of the data format, default "slin" (Signed Linear) */ - inline DataSource(const char* format = "slin") + inline explicit DataSource(const char* format = "slin") : DataNode(format), Mutex(false,"DataSource"), m_nextStamp(invalidStamp()), m_translator(0) { } @@ -611,7 +611,7 @@ protected: * Threaded Source constructor * @param format Name of the data format, default "slin" (Signed Linear) */ - inline ThreadedSource(const char* format = "slin") + inline explicit ThreadedSource(const char* format = "slin") : DataSource(format), m_thread(0) { } @@ -659,7 +659,7 @@ public: * @param sFormat Name of the source format (data received from the consumer) * @param source Optional pointer to a DataSource object */ - DataTranslator(const char* sFormat, DataSource* source = 0); + explicit DataTranslator(const char* sFormat, DataSource* source = 0); /** * Destroys the translator and its source @@ -829,7 +829,7 @@ protected: * Constructor - registers the factory in the global list * @param name Static name of the factory, used for debugging */ - inline TranslatorFactory(const char* name = 0) + inline explicit TranslatorFactory(const char* name = 0) : m_name(name ? name : "?") { DataTranslator::install(this); } @@ -909,7 +909,7 @@ public: /** * Creates an empty data endpoint */ - DataEndpoint(CallEndpoint* call = 0, const char* name = "audio"); + explicit DataEndpoint(CallEndpoint* call = 0, const char* name = "audio"); /** * Endpoint destruct notification, clears source and consumer