Check c++ coding style 54/204454/6
authormk5004.lee <mk5004.lee@samsung.com>
Wed, 24 Apr 2019 05:06:51 +0000 (14:06 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Thu, 25 Apr 2019 00:28:54 +0000 (09:28 +0900)
- cpplint tool

Change-Id: I83e236b689745f9a232b04f67cc987128a41f076
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
15 files changed:
notification-ex/abstract_action.cc
notification-ex/abstract_item.cc
notification-ex/app_control_action.cc
notification-ex/chat_message_item.cc
notification-ex/db_manager.cc
notification-ex/dbus_event_listener.cc
notification-ex/dbus_sender.cc
notification-ex/default_item_factory.cc
notification-ex/event_info.cc
notification-ex/group_item.cc
notification-ex/icon_text_item.cc
notification-ex/manager.cc
notification-ex/stub.cc
notification-ex/time_item.cc
notification-ex/visibility_action.cc

index e37ee52efb43078ace5c3ec26cf7a18204cfdd14..82b388b623a616939e4ed254b0c739209e90a6be 100644 (file)
@@ -61,7 +61,7 @@ Bundle AbstractAction::Serialize() const {
   b.Add(ABSTRACT_ACTION_TYPE_KEY, std::to_string(GetType()));
   b.Add(ABSTRACT_ACTION_IS_LOCAL_KEY, std::to_string(impl_->isLocal_));
   if (!impl_->extra_.empty())
-    b.Add(ABSTRACT_ACTION_EXTRA_KEY ,impl_->extra_);
+    b.Add(ABSTRACT_ACTION_EXTRA_KEYimpl_->extra_);
   return b;
 }
 
index 359680a907b91544a147d9052b7033227ae9b338..f5206b9d1160606377eaf39e4888c53fd3c73be9 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <memory>
 #include <algorithm>
+#include <vector>
 
 #include "notification-ex/exception.h"
 #include "notification-ex/abstract_item.h"
@@ -128,7 +129,7 @@ AbstractItem::~AbstractItem() = default;
 Bundle AbstractItem::Serialize() const {
   Bundle b;
   struct tm timeinfo;
-  char buf[80] = {0,};
+  char buf[80] = {0, };
 
   if (impl_->uid_ == 0)
     impl_->uid_ = getuid();
@@ -260,9 +261,9 @@ void AbstractItem::Deserialize(Bundle b) {
 
   impl_->policy_ = static_cast<Policy>(stoi(policy_str));
 
-  impl_->visible_ = (bool)stoi(b.GetString(ABSTRACT_ITEM_VISIBLE_KEY));
+  impl_->visible_ = static_cast<bool>(stoi(b.GetString(ABSTRACT_ITEM_VISIBLE_KEY)));
 
-  impl_->enable_ = (bool)stoi(b.GetString(ABSTRACT_ITEM_ENABLE_KEY));
+  impl_->enable_ = static_cast<bool>(stoi(b.GetString(ABSTRACT_ITEM_ENABLE_KEY)));
 
   vector<string> receiver_group = b.GetStringArray(ABSTRACT_ITEM_RECEIVER_GROUP_KEY);
   if (receiver_group.size() != 0) {
index d58c8d7ec0fba334af4fa539ce98222aa4342037..2aa94b6d5e3b2769e07f0c32ade657d37f4223af 100644 (file)
@@ -17,6 +17,8 @@
 #include <dlog.h>
 #include <app_control_internal.h>
 
+#include <string>
+
 #include "notification-ex/app_control_action.h"
 #include "notification-ex/app_control_action_implementation.h"
 #include "notification-ex/exception.h"
@@ -143,5 +145,5 @@ app_control_h AppControlAction::GetAppControl() const {
   return impl_->control_;
 }
 
-}  //namespace item
-}  //namespace notification
+}  // namespace item
+}  // namespace notification
index 11e5c4f1464d9972ea209185b25b0da1f84ee18e..ae02fd7ecc3352525603ce27b247772c4b876c6d 100644 (file)
@@ -94,7 +94,7 @@ Bundle ChatMessageItem::Serialize() const {
     reinterpret_cast<char*>(impl_->image_->Serialize().ToRaw().first.get()));
   b.Add(CHATMESSAGE_TIME_KEY,
     reinterpret_cast<char*>(impl_->time_->Serialize().ToRaw().first.get()));
-  b.Add(CHATMESSAGE_TYPE_KEY, std::to_string((int)impl_->type_));
+  b.Add(CHATMESSAGE_TYPE_KEY, std::to_string(static_cast<int>(impl_->type_)));
   return b;
 }
 
@@ -155,4 +155,4 @@ ChatMessageItem::~ChatMessageItem() = default;
 ChatMessageItem::Impl::~Impl() = default;
 
 }  // namespace item
-}  // namespace notification_ex
+}  // namespace notification
index d238706c5c96d99ba32c9b839dee06b83bf78477..d2bef282cfec1f98650ff3ad03dba5f8fd3cab00 100644 (file)
@@ -20,6 +20,7 @@
 #include <vconf.h>
 #include <pkgmgr-info.h>
 #include <tzplatform_config.h>
+
 #include <string.h>
 #include <list>
 #include <map>
index cc03c2cf4fd5744c44619327a926cd3b84e68a40..65962cb37bbb50b5a2fe38b909c4af8238682514 100644 (file)
@@ -18,6 +18,9 @@
 #include <glib.h>
 #include <unistd.h>
 
+#include <string>
+#include <list>
+
 #include "notification-ex/dbus_connection_manager.h"
 #include "notification-ex/dbus_event_listener.h"
 #include "notification-ex/dbus_event_listener_implementation.h"
index 21952359e24e6b6681966d0e6c4c7a3523163267..0fc8dabfc8f75b86df6ed8734762b7ae381263ed 100644 (file)
@@ -18,6 +18,7 @@
 #include <glib.h>
 #include <unistd.h>
 
+#include <string>
 #include <list>
 
 #include "notification-ex/dbus_connection_manager.h"
index 8fa7902a1cf881aff67b47fe5e098e2b4683997b..31917f80b6297428fc4d734123bad3f767ac7d02 100644 (file)
@@ -48,7 +48,7 @@ unique_ptr<AbstractItem> DefaultItemFactory::CreateItem(int type) {
     case AbstractItem::NullObject :
       THROW(ERROR_INVALID_PARAMETER);
     case AbstractItem::Text :
-      return unique_ptr<AbstractItem>(new TextItem("",""));
+      return unique_ptr<AbstractItem>(new TextItem("", ""));
     case AbstractItem::Icon :
       return unique_ptr<AbstractItem>(new IconItem(""));
     case AbstractItem::Image :
index ded0ecf4f04fc0ff0e7194f67ee944e82c3809d5..80fe34a1b78be1841df3dd7496952d0ba588fb87 100644 (file)
@@ -59,22 +59,22 @@ EventInfo::Impl::Impl(EventInfo* parent, int type, std::string owner,
 EventInfo::EventInfo(Bundle serialized)
   : impl_(new Impl(this, EventInfo::Post, "", "", "")) {
   string event_str = serialized.GetString(NOTIFICATION_EX_EVENT_TYPE_KEY);
-  impl_->type_ = (int)strtol(event_str.c_str(), NULL, 10);
+  impl_->type_ = std::stoi(event_str, nullptr, 10);
   impl_->owner_ = serialized.GetString(NOTIFICATION_EX_EVENT_OWNER_KEY);
   impl_->channel_ = serialized.GetString(NOTIFICATION_EX_EVENT_CHANNEL_KEY);
   impl_->item_id_ = serialized.GetString(NOTIFICATION_EX_EVENT_ITEM_ID_KEY);
   string uid_str = serialized.GetString(NOTIFICATION_EX_EVENT_UID_KEY);
-  impl_->uid_ = (uid_t)strtol(uid_str.c_str(), NULL, 10);
+  impl_->uid_ = (uid_t)std::stoi(uid_str, nullptr, 10);
   string request_id_str =
       serialized.GetString(NOTIFICATION_EX_EVENT_REQUEST_ID_KEY);
-  impl_->request_id_ = (int)strtol(request_id_str.c_str(), NULL, 10);
+  impl_->request_id_ = std::stoi(request_id_str, nullptr, 10);
   string error_str =
       serialized.GetString(NOTIFICATION_EX_EVENT_ERROR_KEY);
   impl_->error_ = (NotificationError)strtol(error_str.c_str(), NULL, 10);
 }
 
 string EventInfo::GetString(int type) {
-  switch(type) {
+  switch (type) {
     case Post:
       return "Post";
     case Update:
@@ -92,11 +92,11 @@ string EventInfo::GetString(int type) {
 
 Bundle EventInfo::Serialize() const {
   Bundle serialized;
-  serialized.Add(NOTIFICATION_EX_EVENT_TYPE_KEY, to_string((int)impl_->type_));
+  serialized.Add(NOTIFICATION_EX_EVENT_TYPE_KEY, to_string(static_cast<int>(impl_->type_)));
   serialized.Add(NOTIFICATION_EX_EVENT_OWNER_KEY, impl_->owner_);
   serialized.Add(NOTIFICATION_EX_EVENT_CHANNEL_KEY, impl_->channel_);
   serialized.Add(NOTIFICATION_EX_EVENT_ITEM_ID_KEY, impl_->item_id_);
-  serialized.Add(NOTIFICATION_EX_EVENT_UID_KEY, to_string((int)impl_->uid_));
+  serialized.Add(NOTIFICATION_EX_EVENT_UID_KEY, to_string(static_cast<int>(impl_->uid_)));
   serialized.Add(
       NOTIFICATION_EX_EVENT_REQUEST_ID_KEY, to_string(impl_->request_id_));
   serialized.Add(
index 430a6d1b319609b24ecf3ab31d74089d3f9a436d..2f620755f2b08e82e9ddb4b3a86f1c436d55243f 100644 (file)
@@ -76,7 +76,7 @@ Bundle GroupItem::Serialize() const {
   for (auto& i : impl_->children_list_) {
     Bundle serialized = i.get()->Serialize();
     serialized.Add(
-        GROUP_CHILDREN_TYPE_KEY, to_string((int)i.get()->GetType()));
+        GROUP_CHILDREN_TYPE_KEY, to_string(static_cast<int>(i.get()->GetType())));
     arr.push_back(reinterpret_cast<char*>(serialized.ToRaw().first.get()));
   }
   b.Add(GROUP_CHILDREN_KEY, arr);
@@ -153,14 +153,14 @@ bool GroupItem::IsVertical() {
 }
 
 string GroupItem::GetAppLabel() {
- if (impl_->app_label_.empty()) {
-   char* name;
-   int ret = app_get_name(&name);
-   if (ret != APP_ERROR_NONE)
-     THROW(ERROR_IO_ERROR);
-   impl_->app_label_ = string(name);
- }
- return impl_->app_label_;
 if (impl_->app_label_.empty()) {
+    char* name;
+    int ret = app_get_name(&name);
+    if (ret != APP_ERROR_NONE)
+      THROW(ERROR_IO_ERROR);
+    impl_->app_label_ = string(name);
 }
 return impl_->app_label_;
 }
 
 }  // namespace item
index 813a23056d5d41d859e4dd3c4cb18164486187b4..9718d4ee7474ea7e55963ab5919c342b45e94ce4 100644 (file)
@@ -91,4 +91,4 @@ IconTextItem::~IconTextItem() = default;
 IconTextItem::Impl::~Impl() = default;
 
 }  // namespace item
-}  // namespace notification_ex
+}  // namespace notification
index e5af0fcde5ad9d7322e716c603cd6ef4eb7db224..df4847e5facd717214d4c294a3dbe41e6fb9a737 100644 (file)
@@ -98,7 +98,7 @@ int Manager::GetCount() const {
 }
 
 int Manager::Hide(shared_ptr<item::AbstractItem> noti) {
-  ((IItemInfoInternal*)noti->GetInfo().get())->AddHideViewer(util::GetAppId());
+  (reinterpret_cast<IItemInfoInternal*>(noti->GetInfo().get()))->AddHideViewer(util::GetAppId());
   return impl_->SendNotify(noti, EventInfo::Update);
 }
 
@@ -156,7 +156,7 @@ void Manager::OnEvent(const IEventInfo& info, list<Bundle> serialized) {
     return;
   }
 
-  switch(type) {
+  switch (type) {
     case EventInfo::Post: {
       list<shared_ptr<item::AbstractItem>> added;
       for (auto& i : serialized) {
index 579d421ada4895e56d175ef9adf5dab8d99d98da..13056f8b54b8248e0ff250e587be2de0bd2efeba 100644 (file)
@@ -70,10 +70,11 @@ using namespace notification::item;
 using namespace notification;
 
 namespace {
+
 class Handle {
  public:
-  Handle(item::AbstractItem* ref) : ref_(ref) { }
-  Handle(std::shared_ptr<item::AbstractItem> ptr)
+  explicit Handle(item::AbstractItem* ref) : ref_(ref) { }
+  explicit Handle(std::shared_ptr<item::AbstractItem> ptr)
       : ref_(nullptr), ptr_(move(ptr)) { }
   virtual ~Handle() = default;
   item::AbstractItem* Get() const {
@@ -96,7 +97,6 @@ class Handle {
  private:
   item::AbstractItem* ref_;
   std::shared_ptr<item::AbstractItem> ptr_;
-
 };
 
 class ManagerCallbackInfo {
@@ -111,7 +111,6 @@ class ManagerCallbackInfo {
 
   void InvokeAdded(Manager* manager, const IEventInfo& info,
       list<shared_ptr<AbstractItem>> addedItem) {
-
     noti_ex_item_h* added_item =
         (noti_ex_item_h*)calloc(addedItem.size(), sizeof(noti_ex_item_h));
     if (added_item == nullptr) {
@@ -169,7 +168,6 @@ class ManagerStub : public Manager {
   void OnAdd(const IEventInfo& info,
       list<shared_ptr<AbstractItem>> addedItem) override {
     cb_->InvokeAdded(this, info, addedItem);
-
   }
 
   void OnUpdate(const IEventInfo& info,
@@ -211,7 +209,6 @@ class ReporterCallbackInfo {
 
   void InvokeEvent(Reporter* reporter, const IEventInfo& info,
       list<shared_ptr<AbstractItem>> notiList) {
-
     noti_ex_item_h* noti_list =
         (noti_ex_item_h*)calloc(notiList.size(), sizeof(noti_ex_item_h));
     if (noti_list == nullptr) {
@@ -271,7 +268,8 @@ class ReporterStub : public Reporter {
  private:
   unique_ptr<ReporterCallbackInfo> cb_;
 };
-}
+
+}  // namespace
 
 extern "C" EXPORT_API int noti_ex_action_app_control_create(
     noti_ex_action_h *handle, app_control_h app_control,
@@ -385,7 +383,7 @@ extern "C" EXPORT_API int noti_ex_item_chat_message_create(
           dynamic_pointer_cast<TextItem>(static_cast<Handle*>(text)->GetPtr()),
           dynamic_pointer_cast<ImageItem>(static_cast<Handle*>(image)->GetPtr()),
           dynamic_pointer_cast<TimeItem>(static_cast<Handle*>(time)->GetPtr()),
-          static_cast<ChatMessageItem::Type>((int)message_type));
+          static_cast<ChatMessageItem::Type>(message_type));
   if (p == nullptr) {
     LOGE("Out-of-memory");
     return NOTI_EX_ERROR_OUT_OF_MEMORY;
@@ -1427,7 +1425,7 @@ extern "C" EXPORT_API int noti_ex_action_is_local(noti_ex_action_h handle,
 
 extern "C" EXPORT_API int noti_ex_action_execute(noti_ex_action_h handle,
     noti_ex_item_h item) {
-  if (handle == nullptr || item==nullptr) {
+  if (handle == nullptr || item == nullptr) {
     LOGE("Invalid parameter");
     return NOTI_EX_ERROR_INVALID_PARAMETER;
   }
index b57b9f46fb9a79e60dcff0162598ada9cd36471c..719eb502eff74844cd245a43990f41889ea0991f 100644 (file)
@@ -60,13 +60,13 @@ int TimeItem::GetType() const {
 Bundle TimeItem::Serialize() const {
   Bundle b;
   struct tm timeinfo;
-  char buf[80] = {0,};
+  char buf[80] = {0, };
 
   b = AbstractItem::Serialize();
 
-  //timt_t to tm
+  // timt_t to tm
   localtime_r(&impl_->time_, &timeinfo);
-  //tm to str
+  // tm to str
   strftime (buf, sizeof(buf), "%s", &timeinfo);
   b.Add(TIME_KEY, std::string(buf));
 
@@ -80,9 +80,9 @@ void TimeItem::Deserialize(Bundle b) {
   AbstractItem::Deserialize(b);
   time_s = b.GetString(TIME_KEY);
 
-  //str to tm
+  // str to tm
   strptime(time_s.c_str(), "%s", &timeinfo);
-  //tm to time_t
+  // tm to time_t
   impl_->time_ = mktime(&timeinfo);
 }
 
index f274eb25dd3d5d1780eb3c6072ecf70dd791a71c..f354d98d6b807caaad95faf7984fe16905b4d065 100644 (file)
@@ -14,6 +14,9 @@
  * limitations under the License.
  */
 
+#include <string>
+#include <list>
+
 #include "notification-ex/abstract_item.h"
 #include "notification-ex/visibility_action.h"
 #include "notification-ex/visibility_action_implementation.h"
@@ -124,5 +127,5 @@ void VisibilityAction::SetVisibility(std::string id, bool visible) {
       id, visible));
 }
 
-}  //namespace item
-}  //namespace notification
+}  // namespace item
+}  // namespace notification