本文整理汇总了C++中Nullable::HasValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Nullable::HasValue方法的具体用法?C++ Nullable::HasValue怎么用?C++ Nullable::HasValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nullable
的用法示例。
在下文中一共展示了Nullable::HasValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetQuotesHistoryVersion
int CDataFeed::GetQuotesHistoryVersion(const uint32 timeoutInMilliseconds)
{
Nullable<int> version;
DWORD status = WaitForSingleObject(m_serverQuotesHistoryEvent, 0);
version = m_cache.GetServerQuotesHistoryVersion();
string id;
if (!version.HasValue())
{
id = NextId(cExternalSynchCall);
m_sender->VSendQuotesHistoryRequest(id);
status = WaitForSingleObject(m_serverQuotesHistoryEvent, timeoutInMilliseconds);
version = m_cache.GetServerQuotesHistoryVersion();
}
if (version.HasValue())
{
return version.Value();
}
if (WAIT_OBJECT_0 == status)
{
throw runtime_error("Couldn't get server quotes storage version due to logout");
}
else
{
throw CTimeoutException(id, 0);
}
}
示例2: AssignNextParameter
void Statement::AssignNextParameter(const Nullable<char> &data) {
if (! data.HasValue()) {
AssignNextParameter(new ParamBuffer(MYSQL_TYPE_TINY));
} else {
AssignNextParameter(new ParamBuffer(*data));
}
}
示例3:
void TestNullable::Test3() {
cout << __PRETTY_FUNCTION__ << endl;
Nullable<int> ni;
Nullable<int> ni2(14);
ni = ni2;
UTASSERT(ni.HasValue());
UTASSERT(*ni == 14);
ni.ClearValue();
UTASSERT(!ni);
ni = 9;
UTASSERT(ni.HasValue());
UTASSERT(*ni == 9);
}
示例4: main
int main(int argc, char **argv)
{
ros::init(argc, argv, "trolley");
boost::thread spin_thread(&spinThread);
ros::NodeHandle nh;
ros::Publisher ledPublisher = nh.advertise<kinect_motor::LED>("led", 10);
ros::Publisher motor = nh.advertise<kinect_motor::angle>("angle", 10);
cout << "Start" << endl;
// Prostredi.
Environment * environment = new Environment();
// Nacteni prostredi ze souboru.
environment->Load("configuration.xml");
// Rizeni pohybu robota.
Control control(environment);
while (ros::ok()) {
// Pozice osoby. NITE.
Nullable<XnPoint3D> userPosition = User::getInstance().UserPosition();
// Rizeni pohybu robota.
control.Position(userPosition);
if (userPosition.HasValue()) {
// Osoba byla detekovana.
// Rozsvit celni diodu.
kinect_motor::LED msg;
msg.ledColor = 2;
ledPublisher.publish(msg);
}
else {
// Zhasni celni diodu.
kinect_motor::LED msg;
msg.ledColor = 0;
ledPublisher.publish(msg);
}
}
cout << "Finished" << endl;
spin_thread.join();
delete environment;
return 0;
}
示例5: box_cast
Object* TypedAnimation<T>::GetCurrentValue(Object* defaultOriginValue, Object* defaultDestinationValue, AnimationClock* animationClock)
{
double t = animationClock->get_CurrentProgress();
Nullable<T> from = get_From();
Nullable<T> to = get_To();
if (from.HasValue() && to.HasValue())
{
T value = T(from + (to - from) * t);
return box_cast(value);
}
else if (to.HasValue())
{
ASSERT(0);
return NULL;
}
else
{
return NULL;
}
}
示例6: CollectMargin
bool CSymbolEntry::CollectMargin(const CTradeEntry& entry)
{
Nullable<double> value = entry.GetMargin();
if (!value.HasValue())
{
return false;
}
double margin = value.Value();
if (TradeType_Position == entry.GetType())
{
if (TradeSide_Buy == entry.GetSide())
{
m_buyPositionsMargin += margin;
}
else
{
m_sellPositionsMargin += margin;
}
}
else if (TradeType_Limit == entry.GetType())
{
if (TradeSide_Buy == entry.GetSide())
{
m_buyLimitOrdersMargin += margin;
}
else
{
m_sellLimitOrdersMargin += margin;
}
}
else if (TradeType_Stop == entry.GetType())
{
if (TradeSide_Buy == entry.GetSide())
{
m_buyStopOrdersMargin += margin;
}
else
{
m_sellStopOrdersMargin += margin;
}
}
else
{
throw runtime_error("CSymbolEntry::CollectMargin() unknown type");
}
return true;
}
示例7: SetBooleanValue
void DataRow::SetBooleanValue(int32_t index, const Nullable<bool>& value)
{
ValidateColumnType(index, DataType::Boolean);
if (value.HasValue())
{
uint8_t* copy = static_cast<uint8_t*>(malloc(1));
*copy = static_cast<bool>(value.Value) ? 1 : 0;
m_values[index] = copy;
}
else
{
m_values[index] = nullptr;
}
}
示例8: SetValue
void DataRow::SetValue(int32_t index, const Nullable<T>& value, DataType targetType)
{
ValidateColumnType(index, targetType);
if (value.HasValue())
{
uint8_t* copy = static_cast<uint8_t*>(malloc(sizeof(T)));
memcpy(copy, &value.Value, sizeof(T));
m_values[index] = copy;
}
else
{
m_values[index] = nullptr;
}
}
示例9: SetGuidValue
void DataRow::SetGuidValue(int32_t index, const Nullable<Guid>& value)
{
ValidateColumnType(index, DataType::Guid);
if (value.HasValue())
{
int8_t* copy = static_cast<int8_t*>(malloc(16));
memcpy(copy, static_cast<Guid>(value.Value).data, 16);
m_values[index] = copy;
}
else
{
m_values[index] = nullptr;
}
}
示例10: Process
void Process(const char* name, const Nullable<double> value, std::ostream& stream)
{
if (value.HasValue())
{
Process(name, value.Value(), stream);
}
else
{
if (nullptr != name)
{
stream<<name<<" = ";
}
stream<<"null; ";
}
}
示例11: catch
void TestNullable::Test1() {
cout << __PRETTY_FUNCTION__ << endl;
Nullable<int> ni;
UTASSERT(ni.HasValue() == false);
UTASSERT(!ni);
bool caught = false;
try {
int i = *ni;
UTASSERT(i == 0xBAD); // should never reach this line
} catch (const NullableException &ne) {
caught = true;
}
UTASSERT(caught == true);
}
示例12: SetStringValue
void DataRow::SetStringValue(int32_t index, const Nullable<string>& value)
{
ValidateColumnType(index, DataType::String);
if (value.HasValue())
{
const string& strval = value.Value;
const int32_t length = strval.size();
char* copy = static_cast<char*>(malloc(length + 1));
strcpy_s(copy, length, strval.c_str());
m_values[index] = copy;
}
else
{
m_values[index] = nullptr;
}
}
示例13: SetDecimalValue
void DataRow::SetDecimalValue(int32_t index, const Nullable<decimal_t>& value)
{
ValidateColumnType(index, DataType::Decimal);
if (value.HasValue())
{
// The boost decimal type has a very complex internal representation,
// although slower, it's safer just to store this as a string for now
const string& strval = static_cast<decimal_t>(value.Value).str();
const int32_t length = strval.size();
char* copy = static_cast<char*>(malloc(length + 1));
strcpy_s(copy, length, strval.c_str());
m_values[index] = copy;
}
else
{
m_values[index] = nullptr;
}
}
示例14: myFile
void TestDatabase::Test4() {
cout << __PRETTY_FUNCTION__ << endl;
bool caught = false;
struct stat filestat;
UTASSERT(stat("mike.jpg", &filestat) == 0);
ifstream myFile("pic.jpg", ios::in | ios::binary);
myFile.exceptions(std::ios::failbit);
unsigned char *picBuf = (unsigned char *) malloc(filestat.st_size);
myFile.read((char *)picBuf, filestat.st_size);
myFile.close();
Binary picFromDisk(picBuf, filestat.st_size, filestat.st_size);
try {
Database db("localhost", "root", "", "sakila", 0, NULL, 0);
db.Connect();
Statement stmt(db, "select picture from staff where first_name = ?");
stmt << Nullable<std::string>("Mike") << execute;
UTASSERT(stmt << fetch);
Nullable<Binary> mikepic;
stmt >> mikepic;
UTASSERT(mikepic.HasValue());
UTASSERT(mikepic->BufferLength() == 36365);
UTASSERT((mikepic.const_deref()) == picFromDisk);
} catch (const DatabaseException &de) {
cout << de << endl;
caught = true;
} catch (const NullableException &ne) {
cout << ne << endl;
caught = true;
}
UTASSERT(! caught);
}
示例15: Write
template<typename T> void Write(Nullable<T> const &nv) {
if (nv.HasValue())
Write(nv.Value());
else
WriteNull();
}