本文整理汇总了C++中ola::IntToString方法的典型用法代码示例。如果您正苦于以下问题:C++ ola::IntToString方法的具体用法?C++ ola::IntToString怎么用?C++ ola::IntToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ola
的用法示例。
在下文中一共展示了ola::IntToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testIntToString
/*
* test the IntToString function.
*/
void StringUtilsTest::testIntToString() {
OLA_ASSERT_EQ(string("0"), IntToString(0));
OLA_ASSERT_EQ(string("1234"), IntToString(1234));
OLA_ASSERT_EQ(string("-1234"), IntToString(-1234));
unsigned int i = 42;
OLA_ASSERT_EQ(string("42"), IntToString(i));
}
示例2: Init
/*
* Setup the Node
*/
bool OSCNode::Init() {
// create a new lo_server
// lo_server_new_with_proto doesn't understand that "0" means "any port".
// Instead you have to pass in NULL. Weird.
if (m_listen_port) {
m_osc_server = lo_server_new_with_proto(IntToString(m_listen_port).c_str(),
LO_UDP, OSCErrorHandler);
} else {
m_osc_server = lo_server_new_with_proto(NULL, LO_UDP, OSCErrorHandler);
}
if (!m_osc_server)
return false;
// Get the socket descriptor that liblo is using, create a
// UnmanagedFileDescriptor, assign a callback and register with the
// SelectServer.
int fd = lo_server_get_socket_fd(m_osc_server);
m_descriptor.reset(new ola::io::UnmanagedFileDescriptor(fd));
m_descriptor->SetOnData(NewCallback(this, &OSCNode::DescriptorReady));
m_ss->AddReadDescriptor(m_descriptor.get());
// liblo doesn't support address pattern matching. So rather than registering
// a bunch of handlers, we just register for any address matching the types
// we want, and handle the dispatching ourselves. NULL means 'any address'
// Similarly liblo tries to coerce types so rather than letting it do
// anything we just register for all types and sort it out ourselves.
lo_server_add_method(m_osc_server, NULL, NULL, OSCDataHandler, this);
return true;
}
示例3: IntToString
OSCNode::NodeOSCTarget::NodeOSCTarget(const OSCTarget &target)
: socket_address(target.socket_address),
osc_address(target.osc_address),
liblo_address(lo_address_new(
socket_address.Host().ToString().c_str(),
IntToString(socket_address.Port()).c_str())) {
}
示例4: testGetSetRemove
/*
* Check that we can get/set the preferences
*/
void PreferencesTest::testGetSetRemove() {
MemoryPreferencesFactory factory;
Preferences *preferences = factory.NewPreference("dummy");
string key1 = "foo";
string key2 = "bat";
string value1 = "bar";
string value2 = "baz";
unsigned int value3 = 1;
unsigned int value4 = 2;
int value5 = 3;
int value6 = 4;
// test get/set/has single values string
OLA_ASSERT_EQ(string(""), preferences->GetValue(key1));
preferences->SetValue(key1, value1);
OLA_ASSERT_EQ(value1, preferences->GetValue(key1));
OLA_ASSERT(preferences->HasKey(key1));
preferences->SetValue(key1, value2);
OLA_ASSERT_EQ(value2, preferences->GetValue(key1));
preferences->RemoveValue(key1);
OLA_ASSERT_EQ(string(""), preferences->GetValue(key1));
OLA_ASSERT_FALSE(preferences->HasKey(key1));
// test get/set/has single values uint
OLA_ASSERT_EQ(string(""), preferences->GetValue(key1));
preferences->SetValue(key1, value3);
OLA_ASSERT_EQ(IntToString(value3), preferences->GetValue(key1));
OLA_ASSERT(preferences->HasKey(key1));
preferences->SetValue(key1, value4);
OLA_ASSERT_EQ(IntToString(value4), preferences->GetValue(key1));
preferences->RemoveValue(key1);
OLA_ASSERT_EQ(string(""), preferences->GetValue(key1));
OLA_ASSERT_FALSE(preferences->HasKey(key1));
// test get/set/has single values int
OLA_ASSERT_EQ(string(""), preferences->GetValue(key1));
preferences->SetValue(key1, value5);
OLA_ASSERT_EQ(IntToString(value5), preferences->GetValue(key1));
OLA_ASSERT(preferences->HasKey(key1));
preferences->SetValue(key1, value6);
OLA_ASSERT_EQ(IntToString(value6), preferences->GetValue(key1));
preferences->RemoveValue(key1);
OLA_ASSERT_EQ(string(""), preferences->GetValue(key1));
OLA_ASSERT_FALSE(preferences->HasKey(key1));
vector<string> values;
// test get/set multiple value string
values = preferences->GetMultipleValue(key2);
OLA_ASSERT_EQ((size_t) 0, values.size());
preferences->SetMultipleValue(key2, value1);
values = preferences->GetMultipleValue(key2);
OLA_ASSERT(preferences->HasKey(key2));
OLA_ASSERT_EQ((size_t) 1, values.size());
OLA_ASSERT_EQ(value1, values.at(0));
preferences->SetMultipleValue(key2, value2);
values = preferences->GetMultipleValue(key2);
OLA_ASSERT_EQ((size_t) 2, values.size());
OLA_ASSERT_EQ(value1, values.at(0));
OLA_ASSERT_EQ(value2, values.at(1));
preferences->RemoveValue(key2);
// test get/set multiple value uint
values = preferences->GetMultipleValue(key2);
OLA_ASSERT_EQ((size_t) 0, values.size());
preferences->SetMultipleValue(key2, value3);
values = preferences->GetMultipleValue(key2);
OLA_ASSERT(preferences->HasKey(key2));
OLA_ASSERT_EQ((size_t) 1, values.size());
OLA_ASSERT_EQ(IntToString(value3), values.at(0));
preferences->SetMultipleValue(key2, value4);
values = preferences->GetMultipleValue(key2);
OLA_ASSERT_EQ((size_t) 2, values.size());
OLA_ASSERT_EQ(IntToString(value3), values.at(0));
OLA_ASSERT_EQ(IntToString(value4), values.at(1));
preferences->RemoveValue(key2);
// test get/set multiple value int
values = preferences->GetMultipleValue(key2);
OLA_ASSERT_EQ((size_t) 0, values.size());
preferences->SetMultipleValue(key2, value5);
values = preferences->GetMultipleValue(key2);
OLA_ASSERT(preferences->HasKey(key2));
OLA_ASSERT_EQ((size_t) 1, values.size());
OLA_ASSERT_EQ(IntToString(value5), values.at(0));
preferences->SetMultipleValue(key2, value6);
values = preferences->GetMultipleValue(key2);
OLA_ASSERT_EQ((size_t) 2, values.size());
OLA_ASSERT_EQ(IntToString(value5), values.at(0));
OLA_ASSERT_EQ(IntToString(value6), values.at(1));
preferences->RemoveValue(key2);
// test SetDefaultValue String
OLA_ASSERT(preferences->SetDefaultValue(key1, StringValidator(), value1));
//.........这里部分代码省略.........