本文整理汇总了C++中CVariant::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariant::isNull方法的具体用法?C++ CVariant::isNull怎么用?C++ CVariant::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVariant
的用法示例。
在下文中一共展示了CVariant::isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(TestVariant, VariantTypeNull)
{
CVariant a;
EXPECT_TRUE(a.isNull());
EXPECT_EQ(CVariant::VariantTypeNull, a.type());
}
示例2: Announce
void CAnnouncementManager::Announce(EAnnouncementFlag flag, const char *sender, const char *message, CFileItemPtr item, CVariant &data)
{
// Extract db id of item
CVariant object = data.isNull() || data.isObject() ? data : CVariant::VariantTypeObject;
CStdString type;
int id = 0;
if (item->HasVideoInfoTag())
{
CVideoDatabase::VideoContentTypeToString(item->GetVideoContentType(), type);
id = item->GetVideoInfoTag()->m_iDbId;
}
else if (item->HasMusicInfoTag())
{
type = "music";
id = item->GetMusicInfoTag()->GetDatabaseId();
}
if (id > 0)
{
type += "id";
object[type] = id;
}
Announce(flag, sender, message, object);
}
示例3: Supports
bool CInputStream::Supports(const CFileItem &fileitem)
{
// check if a specific inputstream addon is requested
CVariant addon = fileitem.GetProperty("inputstreamaddon");
if (!addon.isNull())
{
if (addon.asString() != ID())
return false;
else
return true;
}
// check paths
CSingleLock lock(m_parentSection);
bool match = false;
for (auto &path : m_pathList)
{
if (path.empty())
continue;
CRegExp r(true, CRegExp::asciiOnly, path.c_str());
if (r.RegFind(fileitem.GetPath().c_str()) == 0 && r.GetFindLen() > 5)
{
match = true;
break;
}
}
return match;
}
示例4: Announce
void CAnnouncementManager::Announce(EAnnouncementFlag flag, const char *sender, const char *message, CFileItemPtr item, CVariant &data)
{
// Extract db id of item
CVariant object = data.isNull() || data.isObject() ? data : CVariant::VariantTypeObject;
CStdString type;
int id = 0;
if (item->HasVideoInfoTag())
{
CVideoDatabase::VideoContentTypeToString((VIDEODB_CONTENT_TYPE)item->GetVideoContentType(), type);
id = item->GetVideoInfoTag()->m_iDbId;
}
else if (item->HasMusicInfoTag())
{
if (item->IsAlbum())
type = "album";
else
type = "song";
id = item->GetMusicInfoTag()->GetDatabaseId();
}
else
type = "unknown";
object["type"] = type;
if (id > 0)
object["id"] = id;
Announce(flag, sender, message, object);
}
示例5: Announce
void CTCPServer::Announce(EAnnouncementFlag flag, const char *sender, const char *message, const CVariant &data)
{
Value root;
root["jsonrpc"] = "2.0";
root["method"] = "Announcement";
root["params"]["sender"] = sender;
root["params"]["message"] = message;
if (!data.isNull())
data.toJsonValue(root["params"]["data"]);
StyledWriter writer;
std::string str = writer.write(root);
for (unsigned int i = 0; i < m_connections.size(); i++)
{
{
CSingleLock lock (m_connections[i].m_critSection);
if ((m_connections[i].GetAnnouncementFlags() & flag) == 0)
continue;
}
unsigned int sent = 0;
do
{
CSingleLock lock (m_connections[i].m_critSection);
sent += send(m_connections[i].m_socket, str.c_str(), str.size() - sent, sent);
} while (sent < str.size());
}
}
示例6: memset
TEST(TestJSONVariantParser, Parse)
{
CVariant variant;
unsigned char buf[100];
memset(buf, 0, sizeof(buf));
variant = CJSONVariantParser::Parse(buf, sizeof(buf));
EXPECT_TRUE(variant.isNull());
}
示例7: AnnouncePropertyChanged
void CGUIWindowSlideShow::AnnouncePropertyChanged(const std::string &strProperty, const CVariant &value)
{
if (strProperty.empty() || value.isNull())
return;
CVariant data;
data["player"]["playerid"] = PLAYLIST_PICTURE;
data["property"][strProperty] = value;
ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::Player, "xbmc", "OnPropertyChanged", data);
}
示例8: Save
bool CDatabaseQueryRule::Save(CVariant &obj) const
{
if (obj.isNull() || (m_parameter.empty() && m_operator != OPERATOR_TRUE && m_operator != OPERATOR_FALSE))
return false;
obj["field"] = TranslateField(m_field);
obj["operator"] = TranslateOperator(m_operator);
obj["value"] = m_parameter;
return true;
}
示例9: FilterVar
static bool FilterVar(bool valid, const CVariant& variant,
const std::string& check)
{
if (!valid)
return false;
if (variant.isNull() || variant.asString().empty())
return false;
std::string regions = variant.asString();
return regions.find(check) == std::string::npos;
}
示例10: AnnouncePropertyChanged
void CPlayListPlayer::AnnouncePropertyChanged(int iPlaylist, const std::string &strProperty, const CVariant &value)
{
if (strProperty.empty() || value.isNull() ||
(iPlaylist == PLAYLIST_VIDEO && !g_application.m_pPlayer->IsPlayingVideo()) ||
(iPlaylist == PLAYLIST_MUSIC && !g_application.m_pPlayer->IsPlayingAudio()))
return;
CVariant data;
data["player"]["playerid"] = iPlaylist;
data["property"][strProperty] = value;
ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::Player, "xbmc", "OnPropertyChanged", data);
}
示例11: Supports
bool CInputStream::Supports(const CFileItem &fileitem)
{
{
CSingleLock lock(m_parentSection);
auto it = m_configMap.find(ID());
if (it == m_configMap.end())
return false;
if (!it->second.m_ready)
return false;
}
// check if a specific inputstream addon is requested
CVariant addon = fileitem.GetProperty("inputstreamaddon");
if (!addon.isNull())
{
if (addon.asString() != ID())
return false;
else
return true;
}
// check protocols
std::string protocol = fileitem.GetURL().GetProtocol();
if (!protocol.empty())
{
if (std::find(m_protocolsList.begin(),
m_protocolsList.end(), protocol) != m_protocolsList.end())
return true;
}
// check paths
CSingleLock lock(m_parentSection);
auto it = m_configMap.find(ID());
if (it == m_configMap.end())
return false;
bool match = false;
for (auto &path : it->second.m_pathList)
{
if (path.empty())
continue;
CRegExp r(true, CRegExp::asciiOnly, path.c_str());
if (r.RegFind(fileitem.GetPath().c_str()) == 0 && r.GetFindLen() > 5)
{
match = true;
break;
}
}
return match;
}
示例12: Save
bool CDatabaseQueryRule::Save(CVariant &obj) const
{
if (obj.isNull() || (m_parameter.empty() && m_operator != OPERATOR_TRUE && m_operator != OPERATOR_FALSE))
return false;
obj["field"] = TranslateField(m_field);
obj["operator"] = TranslateOperator(m_operator);
obj["value"] = CVariant(CVariant::VariantTypeArray);
for (vector<CStdString>::const_iterator it = m_parameter.begin(); it != m_parameter.end(); it++)
obj["value"].push_back(*it);
return true;
}
示例13: Save
bool CSmartPlaylistRule::Save(CVariant &obj) const
{
if (obj.isNull() || m_parameter.empty())
return false;
CVariant rule(CVariant::VariantTypeObject);
rule["field"] = TranslateField(m_field);
rule["operator"] = TranslateOperator(m_operator);
rule["value"] = CVariant(CVariant::VariantTypeArray);
for (vector<CStdString>::const_iterator it = m_parameter.begin(); it != m_parameter.end(); it++)
rule["value"].push_back(*it);
obj.push_back(rule);
return true;
}
示例14: GetAll
CVariant CDBusUtil::GetAll(const char *destination, const char *object, const char *interface)
{
CDBusMessage message(destination, object, "org.freedesktop.DBus.Properties", "GetAll");
CVariant properties;
message.AppendArgument(interface);
DBusMessage *reply = message.SendSystem();
if (reply)
{
DBusMessageIter iter;
if (dbus_message_iter_init(reply, &iter))
{
if (!dbus_message_has_signature(reply, "a{sv}"))
CLog::Log(LOGERROR, "DBus: wrong signature on GetAll - should be \"a{sv}\" but was %s", dbus_message_iter_get_signature(&iter));
else
{
do
{
DBusMessageIter sub;
dbus_message_iter_recurse(&iter, &sub);
do
{
DBusMessageIter dict;
dbus_message_iter_recurse(&sub, &dict);
do
{
const char * key = NULL;
dbus_message_iter_get_basic(&dict, &key);
if (!dbus_message_iter_next(&dict))
break;
CVariant value = ParseVariant(&dict);
if (!value.isNull())
properties[key] = value;
} while (dbus_message_iter_next(&dict));
} while (dbus_message_iter_next(&sub));
} while (dbus_message_iter_next(&iter));
}
}
}
return properties;
}
示例15: BuildResponse
inline void CJSONRPC::BuildResponse(const CVariant& request, JSON_STATUS code, const CVariant& result, CVariant& response)
{
response["jsonrpc"] = "2.0";
response["id"] = request.isObject() && request.isMember("id") ? request["id"] : CVariant();
switch (code)
{
case OK:
response["result"] = result;
break;
case ACK:
response["result"] = "OK";
break;
case InvalidRequest:
response["error"]["code"] = InvalidRequest;
response["error"]["message"] = "Invalid request.";
break;
case InvalidParams:
response["error"]["code"] = InvalidParams;
response["error"]["message"] = "Invalid params.";
if (!result.isNull())
response["error"]["data"] = result;
break;
case MethodNotFound:
response["error"]["code"] = MethodNotFound;
response["error"]["message"] = "Method not found.";
break;
case ParseError:
response["error"]["code"] = ParseError;
response["error"]["message"] = "Parse error.";
break;
case BadPermission:
response["error"]["code"] = BadPermission;
response["error"]["message"] = "Bad client permission.";
break;
case FailedToExecute:
response["error"]["code"] = FailedToExecute;
response["error"]["message"] = "Failed to execute method.";
break;
default:
response["error"]["code"] = InternalError;
response["error"]["message"] = "Internal error.";
break;
}
}