Use standard types instead of typedefs wherever possible

This commit is contained in:
pd 2008-08-09 01:16:45 +02:00
parent efc594f888
commit f0a9278511
12 changed files with 90 additions and 100 deletions

View file

@ -13,12 +13,12 @@ EchoServer::EchoServer(DBus::Connection &connection)
{
}
DBus::Int32 EchoServer::Random()
int32_t EchoServer::Random()
{
return rand();
}
DBus::String EchoServer::Hello(const DBus::String &name)
std::string EchoServer::Hello(const std::string &name)
{
sleep (10);
return "Hello " + name + "!";
@ -31,33 +31,33 @@ DBus::Variant EchoServer::Echo(const DBus::Variant &value)
return value;
}
std::vector< DBus::Byte > EchoServer::Cat(const DBus::String &file)
std::vector< uint8_t > EchoServer::Cat(const std::string &file)
{
FILE *handle = fopen(file.c_str(), "rb");
if (!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found");
DBus::Byte buff[1024];
uint8_t buff[1024];
size_t nread = fread(buff, 1, sizeof(buff), handle);
fclose(handle);
return std::vector< DBus::Byte > (buff, buff + nread);
return std::vector< uint8_t > (buff, buff + nread);
}
DBus::Int32 EchoServer::Sum(const std::vector<DBus::Int32>& ints)
int32_t EchoServer::Sum(const std::vector<int32_t>& ints)
{
DBus::Int32 sum = 0;
int32_t sum = 0;
for (size_t i = 0; i < ints.size(); ++i) sum += ints[i];
return sum;
}
std::map< DBus::String, DBus::String > EchoServer::Info()
std::map< std::string, std::string > EchoServer::Info()
{
std::map< DBus::String, DBus::String > info;
std::map< std::string, std::string > info;
char hostname[HOST_NAME_MAX];
gethostname(hostname, sizeof(hostname));

View file

@ -13,17 +13,17 @@ public:
EchoServer(DBus::Connection &connection);
DBus::Int32 Random();
int32_t Random();
DBus::String Hello(const DBus::String &name);
std::string Hello(const std::string &name);
DBus::Variant Echo(const DBus::Variant &value);
std::vector< DBus::Byte > Cat(const DBus::String &file);
std::vector< uint8_t > Cat(const std::string &file);
DBus::Int32 Sum(const std::vector<DBus::Int32> & ints);
int32_t Sum(const std::vector<int32_t> & ints);
std::map< DBus::String, DBus::String > Info();
std::map< std::string, std::string > Info();
};
#endif//__DEMO_ECHO_SERVER_H

View file

@ -15,7 +15,7 @@ DBusBrowser::DBusBrowser(::DBus::Connection &conn)
set_border_width(5);
set_default_size(400, 500);
typedef std::vector< ::DBus::String > Names;
typedef std::vector< std::string > Names;
Names names = ListNames();
@ -42,17 +42,17 @@ DBusBrowser::DBusBrowser(::DBus::Connection &conn)
}
void DBusBrowser::NameOwnerChanged(
const ::DBus::String &name, const ::DBus::String &old_owner, const ::DBus::String &new_owner)
const std::string &name, const std::string &old_owner, const std::string &new_owner)
{
cout << name << ": " << old_owner << " -> " << new_owner << endl;
}
void DBusBrowser::NameLost(const ::DBus::String &name)
void DBusBrowser::NameLost(const std::string &name)
{
cout << name << " lost" << endl;
}
void DBusBrowser::NameAcquired(const ::DBus::String &name)
void DBusBrowser::NameAcquired(const std::string &name)
{
cout << name << " acquired" << endl;
}

View file

@ -30,11 +30,11 @@ public:
private:
void NameOwnerChanged(const ::DBus::String &, const ::DBus::String &, const ::DBus::String &);
void NameOwnerChanged(const std::string &, const std::string &, const std::string &);
void NameLost(const ::DBus::String &);
void NameLost(const std::string &);
void NameAcquired(const ::DBus::String &);
void NameAcquired(const std::string &);
void on_select_busname();

View file

@ -10,9 +10,9 @@ HalManagerProxy::HalManagerProxy(DBus::Connection &connection)
connect_signal(HalManagerProxy, DeviceAdded, DeviceAddedCb);
connect_signal(HalManagerProxy, DeviceRemoved, DeviceRemovedCb);
std::vector< DBus::String > devices = GetAllDevices();
std::vector< std::string > devices = GetAllDevices();
std::vector< DBus::String >::iterator it;
std::vector< std::string >::iterator it;
for (it = devices.begin(); it != devices.end(); ++it)
{
DBus::Path udi = *it;
@ -23,9 +23,9 @@ HalManagerProxy::HalManagerProxy(DBus::Connection &connection)
}
}
std::vector< DBus::String > HalManagerProxy::GetAllDevices()
std::vector< std::string > HalManagerProxy::GetAllDevices()
{
std::vector< DBus::String > udis;
std::vector< std::string > udis;
DBus::CallMessage call;
call.member("GetAllDevices");
@ -40,7 +40,7 @@ std::vector< DBus::String > HalManagerProxy::GetAllDevices()
void HalManagerProxy::DeviceAddedCb(const DBus::SignalMessage &sig)
{
DBus::MessageIter it = sig.reader();
DBus::String devname;
std::string devname;
it >> devname;
@ -53,7 +53,7 @@ void HalManagerProxy::DeviceAddedCb(const DBus::SignalMessage &sig)
void HalManagerProxy::DeviceRemovedCb(const DBus::SignalMessage &sig)
{
DBus::MessageIter it = sig.reader();
DBus::String devname;
std::string devname;
it >> devname;
@ -72,10 +72,10 @@ HalDeviceProxy::HalDeviceProxy(DBus::Connection &connection, DBus::Path &udi)
void HalDeviceProxy::PropertyModifiedCb(const DBus::SignalMessage &sig)
{
typedef DBus::Struct< DBus::String, DBus::Bool, DBus::Bool > HalProperty;
typedef DBus::Struct< std::string, bool, bool > HalProperty;
DBus::MessageIter it = sig.reader();
DBus::Int32 number;
int32_t number;
it >> number;
@ -94,7 +94,7 @@ void HalDeviceProxy::PropertyModifiedCb(const DBus::SignalMessage &sig)
void HalDeviceProxy::ConditionCb(const DBus::SignalMessage &sig)
{
DBus::MessageIter it = sig.reader();
DBus::String condition;
std::string condition;
it >> condition;

View file

@ -15,7 +15,7 @@ public:
HalManagerProxy(DBus::Connection &connection);
std::vector< DBus::String > GetAllDevices();
std::vector< std::string > GetAllDevices();
private:
@ -23,7 +23,7 @@ private:
void DeviceRemovedCb(const DBus::SignalMessage &sig);
std::map< DBus::String, DBus::RefPtr< HalDeviceProxy > > _devices;
std::map< std::string, DBus::RefPtr< HalDeviceProxy > > _devices;
};
class HalDeviceProxy

View file

@ -12,11 +12,11 @@ PropsServer::PropsServer(DBus::Connection &connection)
}
void PropsServer::on_set_property
(DBus::InterfaceAdaptor &interface, const DBus::String &property, const DBus::Variant &value)
(DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value)
{
if (property == "Message")
{
DBus::String msg = value;
std::string msg = value;
this->MessageChanged(msg);
}
}

View file

@ -15,7 +15,7 @@ public:
PropsServer(DBus::Connection &connection);
void on_set_property
(DBus::InterfaceAdaptor &interface, const DBus::String &property, const DBus::Variant &value);
(DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value);
};
#endif//__DEMO_PROPS_SERVER_H