本文整理汇总了C++中User函数的典型用法代码示例。如果您正苦于以下问题:C++ User函数的具体用法?C++ User怎么用?C++ User使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了User函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: baseAuth
User AuthModel::processAuthToken()
{
WApplication *app = WApplication::instance();
const WEnvironment& env = app->environment();
if (baseAuth()->authTokensEnabled()) {
const std::string *token =
env.getCookie(baseAuth()->authTokenCookieName());
if (token) {
AuthTokenResult result = baseAuth()->processAuthToken(*token, users());
switch(result.state()) {
case AuthTokenState::Valid: {
if (!result.newToken().empty()) {
/*
* Only extend the validity from what we had currently.
*/
app->setCookie(baseAuth()->authTokenCookieName(), result.newToken(),
result.newTokenValidity(), "", "", app->environment().urlScheme() == "https");
}
return result.user();
}
case AuthTokenState::Invalid:
app->setCookie(baseAuth()->authTokenCookieName(),std::string(), 0, "", "", app->environment().urlScheme() == "https");
return User();
}
}
}
return User();
}
示例2:
Tweet::Tweet(const QJsonObject &json)
{
// Use the retweeted status when possible
QJsonObject tweet {json};
QJsonObject retweetedTweet {json.value(QLatin1String("retweeted_status")).toObject()};
QJsonObject displayedTweet {tweet};
if (!retweetedTweet.isEmpty()) {
displayedTweet = retweetedTweet;
// Adding the retweeting user when retweeting
m_retweetingUser = std::move(User(tweet.value(QLatin1String("user")).toObject()));
}
m_id = std::move(tweet.value(QLatin1String("id_str")).toString());
m_originalId = std::move(displayedTweet.value(QLatin1String("id_str")).toString());
m_text = std::move(displayedTweet.value(QLatin1String("text")).toString());
m_favoriteCount = displayedTweet.value(QLatin1String("favorite_count")).toInt();
m_favorited = displayedTweet.value(QLatin1String("favorited")).toBool();
m_retweetCount = displayedTweet.value(QLatin1String("retweet_count")).toInt();
m_retweeted = displayedTweet.value(QLatin1String("retweeted")).toBool();
m_inReplyTo = std::move(displayedTweet.value(QLatin1String("in_reply_to_status_id")).toString());
m_source = std::move(tweet.value(QLatin1String("source")).toString());
m_timestamp = std::move(private_util::fromUtc(displayedTweet.value(QLatin1String("created_at")).toString()));
m_user = std::move(User(displayedTweet.value(QLatin1String("user")).toObject()));
QJsonObject entities {displayedTweet.value(QLatin1String("entities")).toObject()};
QJsonObject extendedEntities {displayedTweet.value(QLatin1String("extended_entities")).toObject()};
m_entities = Entity::create(entities, extendedEntities);
m_quotedStatus = std::move(QuotedTweet(displayedTweet.value(QLatin1String("quoted_status")).toObject()));
}
示例3: events
std::vector<Event> Event::select(std::string cond, int limit){
DB::Result r = DB::query("SELECT type, source_id, source_name, target_id, target_name, track_id, track_title, message, date AT TIME ZONE 'UTC', id FROM events" + (cond.empty()?"":" WHERE "+cond) + " ORDER BY date DESC" + (limit?" LIMIT "+number(limit):""));
std::vector<Event> events(r.size());
for(unsigned i=0; i<r.size(); i++){
Type t = r[i][0] == "publish" ? Publish
: r[i][0] == "comment" ? Comment
: r[i][0] == "favorite" ? Favorite : Follow;
events[i] = Event(t, User(number(r[i][1]),r[i][2]), User(number(r[i][3]),r[i][4]), Track(number(r[i][5]),r[i][6]), r[i][7], r[i][8], number(r[i][9]));
}
return events;
}
示例4: registerTestUsers
// Since we don't support CreateSecurityGroup, insert a few for testing.
void registerTestUsers() {
users[ "1" ] = User();
users[ "1" ].groups[ "sg-name-1" ] = Group( "sg-name-1" );
users[ "1" ].groups[ "sg-name-2" ] = Group( "sg-name-2" );
users[ "1" ].groups[ "sg-name-3" ] = Group( "sg-name-3" );
// The Amazon EC2 ID we actually use for testing.
users[ "1681MPTCV7E5BF6TWE02" ] = User();
// The Magellan (Eucalyptus) ID we actually use for testing.
users[ "HOq1jQmeoswWXoJTq44DbTuD8jchkWfXmbsEg" ] = User();
}
示例5: follow
void follow(int followerId, int followeeId) {
int flag = 0 ;
int flag1 = 0 ;
int ret = 0 , i = 0 ,followeri=-1, followeei = -1 ;
User *user1 =NULL;
list <int> * tweetid2 =NULL, * tweetdate2 =NULL;
for( vector<User>::iterator iter = user.begin(); iter != user.end() ;++iter,++i){
if( iter->getuserid() == followerId ){
flag1 = 1 ;
ret = iter->addfollower(followeeId);
user1 = &*iter ;
followeri = i ;
if( ret == 1 ){
return ;
}
}
if( iter->getuserid() == followeeId ){
flag = 1 ;
followeei = i ;
}
if( flag==1 && flag1 == 1 ){
break ;
}
}
if( flag1 == 0 ){
user.push_back(User(followerId));
user.back().addfollower(followeeId);
user1 = &user.back();
}
else{
user1 = &user[followeri];
}
if( flag != 0){
user[followeei].addfollowee(followerId);
tweetid2 = &user[followeei].getmytweetid() ;
tweetdate2 = &user[followeei].getmytweetdate() ;
updatetweetid( user1 , followeeId, tweetid2 , tweetdate2 );
}
else{
user.push_back(User(followeeId));
user.back().addfollowee(followerId);
}
}
示例6: m_username
UserItemWidget::UserItemWidget(const QString& username)
: m_username(username)
{
// subscribers can listen to loved tracks and personal tags.
bool subscriber = false;
{
unicorn::UserSettings us;
QVariant v = us.value(unicorn::UserSettings::subscriptionKey(), false);
subscriber = v.toBool();
}
// todo: no reason username can't come from the model...
QPushButton* del;
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget( m_image = new QLabel );
QVBoxLayout* vlayout = new QVBoxLayout();
vlayout->addWidget( m_label = new QLabel );
vlayout->addWidget( m_combo = new QComboBox() );
vlayout->addWidget( m_playlistCombo = new QComboBox() );
vlayout->addWidget( m_tagCombo = new QComboBox() );
m_playlistCombo->setVisible(false);
m_tagCombo->setVisible(false);
m_combo->addItem( "Library", RqlSource::User );
if (subscriber) {
m_combo->addItem( "Loved Tracks", RqlSource::Loved );
} else {
// would be nice to show the option in a disabled state.
// how?
// fixme.
}
m_combo->addItem( "Recommended", RqlSource::Rec );
m_combo->addItem( "Neighbours", RqlSource::Neigh );
connect(m_combo, SIGNAL(currentIndexChanged(int)), SLOT(onComboChanged(int)));
connect(m_playlistCombo, SIGNAL(currentIndexChanged(int)), SLOT(onCombo2Changed(int)));
connect(m_tagCombo, SIGNAL(currentIndexChanged(int)), SLOT(onCombo2Changed(int)));
layout->addLayout( vlayout );
layout->addWidget( del = new QPushButton("X"), 0, Qt::AlignRight );
m_image->setObjectName( "userImage" );
m_image->setProperty( "noImage", true );
m_label->setText( username );
connect(del, SIGNAL(clicked()), SIGNAL(deleteClicked()));
if (subscriber) {
connect(User(username).getPlaylists(), SIGNAL(finished()), SLOT(onGotPlaylists()));
connect(User(username).getTopTags(), SIGNAL(finished()), SLOT(onGotTags()));
}
}
示例7: waitForNewFriend
// Function: waitForNewFriend
// Inputs: NA
// Outputs: true if executed to fruition, false if no user active.
// Description: This function wait for a user to input the name of a frined they
// want to add then stores the friendship in the user list.
//
bool Menu::waitForNewFriend()
{
// Check to see if there is an active user.
if (users.hasNoActiveUser())
{
std::cout << NEW_LINE << TAB << TAB << STRING_NO_USER_ACTIVE;
return false;
}
// Display prompt for a new friend.
std::cout << NEW_LINE + TAB + TAB + STRING_ENTER_NEW_FRIEND;
// Read a line from the console.
std::string newFriend;
std::getline(std::cin, newFriend);
// Check if username is empty.
if ( newFriend.length() == 0)
{
std::cout << NEW_LINE << TAB << TAB << STRING_USER_NOT_BLANK;
return waitForNewFriend();
}
// Check if username is formatted correctly.
else if ( newFriend.find(" ") != std::string::npos)
{
std::cout << NEW_LINE << TAB << TAB << STRING_USER_FORMAT;
return waitForNewFriend();
}
else
{
// Check to see if the name entered is a valid user.
if ( !users.isUser(User(newFriend)) )
{
std::cout << NEW_LINE + TAB + TAB + STRING_NO_USER;
return waitForCommand();
}
// Check to see if the name belongs to the current user.
if ( users.getCurrentUser().getUsername().compare(newFriend) == 0 )
{
std::cout << NEW_LINE + TAB + TAB + STRING_CANNOT_FRIEND_SELF;
return waitForCommand();
}
// Check to see if the current user is already friends with newFriend.
if ( users.isFriend(users.getCurrentUser(), users.findUserByName(newFriend)) )
{
std::cout << NEW_LINE + TAB + TAB + STRING_ALREADY_FRIENDS;
return waitForCommand();
}
std::cout << NEW_LINE << TAB << TAB << STRING_NOW_FRIENDS << newFriend << NEW_LINE;
// Add the friend to the current user's friends list.
users.setFriends(users.getCurrentUser(),users.findUserByName(newFriend));
return true;
}
}
示例8: User
RadioStation
PlayableItemWidget::getMultiStation() const
{
QList<User> users;
int endPos = m_rs.url().indexOf( "/", 14 );
if ( endPos == -1 )
endPos = m_rs.url().length();
users << User( m_rs.url().mid( 14, endPos - 14 ) );
users << User();
RadioStation station = RadioStation::library( users );
station.setTitle( tr( "Multi-Library Radio" ) );
return station;
}
示例9: qDebug
void UserManagerBackend::refreshUsers() {
qDebug() << "Refreshing user list...";
userList.clear();
QFile userFile(chroot + "/etc/passwd");
if ( userFile.open(QIODevice::ReadOnly) ) {
QTextStream stream(&userFile);
stream.setCodec("UTF-8");
QString line;
while ( !stream.atEnd() ) {
line = stream.readLine();
if ((line.indexOf("#") != 0) && (! line.isEmpty())) { //Make sure it isn't a comment or blank
QString username = line.section(":",0,0);
int uid = line.section(":",2,2).toInt();
int gid = line.section(":",3,3).toInt();
QString home = line.section(":",5,5);
QString shell = line.section(":",6,6);
QString fullname = line.section(":",4,4);
userList[username] = User(username, uid, gid, home, shell, fullname);
}
}
}
else {
//Unable to open file error
qWarning("Error! Unable to open /etc/passwd");
}
}
示例10: file
// Returns vector with all users information.
std::vector<User> RadioStation::loadAllUsersToVector() {
std::vector <User> allUsersVec;
std::string filename = "users.csv";
ifstream file(filename);
std::string tempStr;
// Temporary user information.
unsigned int newID, newAge, newHits;
std::string newName, newGender, newPass;
bool newSpecial;
if(file.is_open()) {
getline(file, tempStr); // Get first line (fields titles).
while(getline(file, tempStr)) {
// Gets user information from file.
newID = convertStrInt(extractInfo(tempStr));
newName = extractInfo(tempStr);
newAge = convertStrInt(extractInfo(tempStr));
newGender = extractInfo(tempStr);
newSpecial = convertToBool(convertStrInt(extractInfo(tempStr)));
newPass = extractInfo(tempStr);
newHits = convertStrInt(extractInfo(tempStr));
// Stores user information to vector.
allUsersVec.push_back(User(newID, newName, newAge, newGender, newSpecial, newPass, newHits, true));
}
file.close();
}
return allUsersVec;
}
示例11: ui
FriendWidget::FriendWidget( const lastfm::XmlQuery& user, QWidget* parent)
:QFrame( parent ),
ui( new Ui::FriendWidget ),
m_user( user ),
m_order( 0 - 1 ),
m_listeningNow( false )
{
ui->setupUi( this );
layout()->setAlignment( ui->avatar, Qt::AlignTop );
m_movie = new QMovie( ":/icon_eq.gif", "GIF", this );
m_movie->setCacheMode( QMovie::CacheAll );
ui->equaliser->setMovie( m_movie );
ui->equaliser->hide();
update( user, -1 );
QRegExp re( "/serve/(\\d*)s?/" );
ui->avatar->loadUrl( user["image size=medium"].text().replace( re, "/serve/\\1s/" ), HttpImageWidget::ScaleNone );
ui->avatar->setHref( user["url"].text() );
ui->radio->setStation( RadioStation::library( User( user["name"].text() ) ), tr("%1%2s Library Radio").arg( user["name"].text(), QChar(0x2019) ), "" );
ui->avatar->setUser( m_user );
}
示例12: messageReceived
bool lmcMessaging::addUser(QString szUserId, QString szVersion, QString szAddress, QString szName, QString szStatus,
QString szAvatar, QString szNote, QString szCaps) {
for(int index = 0; index < userList.count(); index++)
if(userList[index].id.compare(szUserId) == 0)
return false;
lmcTrace::write("Adding new user: " + szUserId + ", " + szVersion + ", " + szAddress);
if(!userGroupMap.contains(szUserId) || !groupList.contains(Group(userGroupMap.value(szUserId))))
userGroupMap.insert(szUserId, GRP_DEFAULT_ID);
int nAvatar = szAvatar.isNull() ? -1 : szAvatar.toInt();
userList.append(User(szUserId, szVersion, szAddress, szName, szStatus, userGroupMap[szUserId],
nAvatar, szNote, QString::null, szCaps));
if(!szStatus.isNull()) {
XmlMessage xmlMessage;
xmlMessage.addHeader(XN_FROM, szUserId);
xmlMessage.addData(XN_STATUS, szStatus);
// send a status message to app layer, this is different from announce message
emit messageReceived(MT_Status, &szUserId, &xmlMessage);
int statusIndex = Helper::statusIndexFromCode(szStatus);
if(statusType[statusIndex] == StatusTypeOffline) // offline status
return false; // no need to send a new user message to app layer
}
emit messageReceived(MT_Announce, &szUserId, NULL);
return true;
}
示例13: QMenu
void
PlayableItemWidget::contextMenuEvent( QContextMenuEvent* event )
{
QMenu* contextMenu = new QMenu( this );
contextMenu->addAction( tr( "Play %1" ).arg( m_rs.title() ), this, SLOT(play()));
if ( RadioService::instance().state() == Playing )
contextMenu->addAction( tr( "Cue %1" ).arg( m_rs.title() ), this, SLOT(playNext()));
if ( m_rs.url().startsWith( "lastfm://user/" )
&& ( m_rs.url().endsWith( "/library" ) || m_rs.url().endsWith( "/personal" ) )
&& m_rs.url() != RadioStation::library( User() ).url() )
{
int endPos = m_rs.url().indexOf( "/", 14 );
if ( endPos == -1 )
endPos = m_rs.url().length();
// if it's a user station that isn't yours we should
// let them start a multi-station with yours
contextMenu->addSeparator();
contextMenu->addAction( tr( "Play %1 and %2 Library Radio" ).arg( m_rs.url().mid( 14, endPos - 14 ), User().name() ), this, SLOT(playMulti()));
if ( RadioService::instance().state() == Playing )
contextMenu->addAction( tr( "Cue %1 and %2 Library Radio" ).arg( m_rs.url().mid( 14, endPos - 14 ), User().name() ), this, SLOT(playMultiNext()));
}
if ( contextMenu->actions().count() )
contextMenu->exec( event->globalPos() );
}
示例14: ReadLong
void SMsgUsrGetPolledUserListReplyEx::unpack_multiple_message_specific_data()
{
// Retrieve the data source id
m_i_data_source_id = ReadLong();
// Retrieve the data source specific status information
m_data_source_specific_status = static_cast<WONMsg::ServerStatus>(static_cast<short>(ReadShort()));
// Retrieve the number of users found
unsigned long number_of_user_objects = ReadLong();
// Retrieve each user, adding each user to the end of the user vector array
for (unsigned long counter = 0;
counter < number_of_user_objects;
counter++)
{
// Add a new user to the end of the array
m_a_users.push_back(User());
m_a_users.back().unpack_data(*this);
}
}
示例15: m_me
/** @brief NoGuiSinglePlayerBattle
*
* @todo: document this function
*/
NoGuiSinglePlayerBattle::NoGuiSinglePlayerBattle()
: m_me( User( usync().IsLoaded() ? usync().GetDefaultNick() : _T("invalid") ) )
{
OnUserAdded( m_me );
m_me.BattleStatus().colour = sett().GetBattleLastColour();
SetFounder( m_me.GetNick() );
}