当前位置: 首页>>代码示例>>C++>>正文


C++ StringPrintf函数代码示例

本文整理汇总了C++中StringPrintf函数的典型用法代码示例。如果您正苦于以下问题:C++ StringPrintf函数的具体用法?C++ StringPrintf怎么用?C++ StringPrintf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了StringPrintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CHECK

void NuPlayer::Decoder::configure(const sp<AMessage> &format) {
    CHECK(mCodec == NULL);

    AString mime;
    CHECK(format->findString("mime", &mime));

    sp<AMessage> notifyMsg =
        new AMessage(kWhatCodecNotify, id());

    mCSDIndex = 0;
    for (size_t i = 0;; ++i) {
        sp<ABuffer> csd;
        if (!format->findBuffer(StringPrintf("csd-%d", i).c_str(), &csd)) {
            break;
        }

        mCSD.push(csd);
    }

#ifdef QCOM_HARDWARE
    sp<ABuffer> extendedCSD = ExtendedCodec::getRawCodecSpecificData(format);
    if (extendedCSD != NULL) {
        ALOGV("pushing extended CSD of size %d", extendedCSD->size());
        mCSD.push(extendedCSD);
    }

    sp<ABuffer> aacCSD = ExtendedCodec::getAacCodecSpecificData(format);
    if (aacCSD != NULL) {
        ALOGV("pushing AAC CSD of size %d", aacCSD->size());
        mCSD.push(aacCSD);
    }
#endif

    if (mNativeWindow != NULL) {
        format->setObject("native-window", mNativeWindow);
    }

    // Current video decoders do not return from OMX_FillThisBuffer
    // quickly, violating the OpenMAX specs, until that is remedied
    // we need to invest in an extra looper to free the main event
    // queue.
    bool needDedicatedLooper = !strncasecmp(mime.c_str(), "video/", 6);

    mFormat = format;
    mCodec = new ACodec;

    if (needDedicatedLooper && mCodecLooper == NULL) {
        mCodecLooper = new ALooper;
        mCodecLooper->setName("NuPlayerDecoder");
        mCodecLooper->start(false, false, ANDROID_PRIORITY_AUDIO);
    }

    (needDedicatedLooper ? mCodecLooper : looper())->registerHandler(mCodec);

    mCodec->setNotificationMessage(notifyMsg);
    mCodec->initiateSetup(format);
}
开发者ID:AOSB,项目名称:android_frameworks_av,代码行数:57,代码来源:NuPlayerDecoder.cpp

示例2: CHECK

sp<AMessage> DashPlayer::Decoder::makeFormat(const sp<MetaData> &meta) {
    CHECK(mCSD.isEmpty());

    sp<AMessage> msg;
    uint32_t type;
    const void *data;
    size_t size;

    CHECK_EQ(convertMetaDataToMessage(meta, &msg), (status_t)OK);

    int32_t value;
    if (meta->findInt32(kKeySmoothStreaming, &value)) {
        msg->setInt32("smooth-streaming", value);
    }

    if (meta->findInt32(kKeyIsDRM, &value)) {
        msg->setInt32("secure-op", 1);
    }

    if (meta->findInt32(kKeyRequiresSecureBuffers, &value)) {
        msg->setInt32("requires-secure-buffers", 1);
    }

    if (meta->findInt32(kKeyEnableDecodeOrder, &value)) {
        msg->setInt32("decodeOrderEnable", value);
    }
    if (meta->findData(kKeyAacCodecSpecificData, &type, &data, &size)) {
          if (size > 0 && data != NULL) {
              sp<ABuffer> buffer = new ABuffer(size);
              if (buffer != NULL) {
                memcpy(buffer->data(), data, size);
                buffer->meta()->setInt32("csd", true);
                buffer->meta()->setInt64("timeUs", 0);
                msg->setBuffer("csd-0", buffer);
              }
              else {
                ALOGE("kKeyAacCodecSpecificData ABuffer Allocation failed");
              }
          }
          else {
              ALOGE("Not a valid data pointer or size == 0");
          }
    }


    mCSDIndex = 0;
    for (size_t i = 0;; ++i) {
        sp<ABuffer> csd;
        if (!msg->findBuffer(StringPrintf("csd-%d", i).c_str(), &csd)) {
            break;
        }

        mCSD.push(csd);
    }

    return msg;
}
开发者ID:Android-Butter,项目名称:butter_hardware_qcom_media-caf,代码行数:57,代码来源:DashPlayerDecoder.cpp

示例3: StringPrintf

// static
std::string JSONReader::FormatErrorMessage(int line, int column,
        const std::string& description)
{
    if(line || column)
    {
        return StringPrintf("Line: %i, column: %i, %s",
                            line, column, description.c_str());
    }
    return description;
}
开发者ID:kanego,项目名称:CoreProject,代码行数:11,代码来源:json_reader.cpp

示例4: MY_LOGI

void SfDelegate::setProxy(const char *proxy, int port)
{
       std::string host = proxy;
	 std::string list = "";

	 MY_LOGI(StringPrintf("setProxy:host=%s,port=%d",host.c_str() ,port).c_str());
    
	gProxyConfigService.get()->UpdateProxySettings(host,list);

}
开发者ID:LuckJC,项目名称:pro-fw,代码行数:10,代码来源:support.cpp

示例5: StringPrintf

void EventGraphFixer::addEventAfterTargetHappensBefore() {
	std::string node_id;
	int num_arcs_added = 0;
	std::map<std::string, int> m_lastLoc;
	for (int event_action_id = 0; event_action_id <= m_log->maxEventActionId();
			++event_action_id) {
		if (m_eventGraph->isNodeDeleted(event_action_id))
			continue;
		const ActionLog::EventAction& op = m_log->event_action(event_action_id);
		for (size_t i = 0; i < op.m_commands.size(); ++i) {
			const ActionLog::Command& cmd = op.m_commands[i];
			if (cmd.m_cmdType == ActionLog::WRITE_MEMORY) {
				if (getTargetNodeString(m_vars->getString(cmd.m_location),
						&node_id)) {
					m_lastLoc[node_id] = event_action_id;
					m_log->mutable_event_action(event_action_id)->m_commands[i].m_location =
							m_vars->addString(
									StringPrintf("%s-%d",
											m_vars->getString(cmd.m_location),
											event_action_id).c_str());
				}
			} else if (cmd.m_cmdType == ActionLog::READ_MEMORY) {
				if (getTargetNodeString(m_vars->getString(cmd.m_location),
						&node_id)) {
					std::map<std::string, int>::const_iterator it =
							m_lastLoc.find(node_id);
					if (it != m_lastLoc.end()) {
						if (m_eventGraph->addArcIfNeeded(it->second,
								event_action_id))
							++num_arcs_added;
						m_log->mutable_event_action(event_action_id)->m_commands[i].m_location =
								m_vars->addString(
										StringPrintf("%s-%d",
												m_vars->getString(
														cmd.m_location),
												it->second).c_str());
					}
				}
			}
		}
	}
	printf("Added %d event arcs\n", num_arcs_added);
}
开发者ID:zhanglu623,项目名称:EventRacer-WebKit,代码行数:43,代码来源:GraphFix.cpp

示例6: StringPrintf

// static
void HTTPStream::RegisterSocketUser(int s, uid_t uid) {
    // Lower bits MUST be 0.
    static const uint64_t kTag = 0xdeadbeef00000000ll;

    AString line = StringPrintf("t %d %llu %d", s, kTag, uid);

    int fd = open("/proc/net/xt_qtaguid/ctrl", O_WRONLY);
    write(fd, line.c_str(), line.size());
    close(fd);
    fd = -1;
}
开发者ID:AshutoshY,项目名称:ics4blade,代码行数:12,代码来源:HTTPStream.cpp

示例7: while

void SfDelegate::readMore(net::URLRequest *request) {
    while (mNumBytesRead < mNumBytesTotal) {
        size_t copy = mNumBytesTotal - mNumBytesRead;
        if (copy > mReadBuffer->size()) {
            copy = mReadBuffer->size();
        }

        int n;
        if (request->Read(mReadBuffer, copy, &n)) {
            MY_LOGV(StringPrintf("Read %d bytes directly.", n).c_str());

            CHECK_LE((size_t)n, copy);

            memcpy((uint8_t *)mDataDestination + mNumBytesRead,
                   mReadBuffer->data(),
                   n);

            mNumBytesRead += n;

            if (n == 0) {
                mAtEOS = true;
                break;
            }
        } else {
            MY_LOGV("readMore pending read");

            if (request->status().status() != net::URLRequestStatus::IO_PENDING) {
                MY_LOGI(StringPrintf(
                            "Direct read failed w/ status %d\n",
                            request->status().status()).c_str());

                mOwner->onReadCompleted(ERROR_IO);
                return;
            }

            return;
        }
    }

    mOwner->onReadCompleted(mNumBytesRead);
}
开发者ID:Dm47021,项目名称:chaos_frameworks_av,代码行数:41,代码来源:support.cpp

示例8: SubAddDropResponseMessage

static string SubAddDropResponseMessage(uint8_t code) {
  switch (code) {
  case sub_adddrop_already_there: return "You are already there";
  case sub_adddrop_error: return "Error Adding or Droppign Sub";
  case sub_adddrop_not_allowed: return "Not allowed to add or drop this sub";
  case sub_adddrop_not_host: return "This system is not the host";
  case sub_adddrop_not_there: return "You were not subscribed to the sub";
  case sub_adddrop_ok: return "Add or Drop successful";
  default: return StringPrintf("Unknown response code %d", code);
  }

}
开发者ID:wwivbbs,项目名称:wwiv,代码行数:12,代码来源:subs.cpp

示例9: StringPrintf

void TimeFmt::printCustom(int sec, const char *buf, int bufsize, const char *str_sep, const char *str_seconds, const char *str_minutes, const char *str_hours, const char *str_days) {
  if (buf == NULL || bufsize == 0) return;
  char *p = (char *)buf;
  *p = 0;
  int days, hours, minutes;
  String s;

  if (str_days) {
    days = sec / (3600*24);
    sec -= days * (3600*24);
    if (days != 0) {
      s += StringPrintf("%d%s", days, str_days);
    }
  }
  if (str_hours) {
    hours = sec / 3600;
    sec -= hours * 3600;
    if (hours != 0) {
      if (!s.isempty()) s += str_sep;
      s += StringPrintf("%d%s", hours, str_hours);
    }
  }
  if (str_minutes) {
    minutes = sec / 60;
    sec -= minutes * 60;
    if (minutes != 0) {
      if (!s.isempty()) s += str_sep;
      s += StringPrintf("%d%s", minutes, str_minutes);
    }
  }
  if (str_seconds) {
    if (sec != 0) {
      if (!s.isempty()) s += str_sep;
      s += StringPrintf("%d%s", sec, str_seconds);
    }
  }
  STRNCPY(p, s.getValue(), bufsize);
  int l = s.len();
  if (l < bufsize) p[l] = 0;
}
开发者ID:bizzehdee,项目名称:wasabi,代码行数:40,代码来源:timefmt.cpp

示例10: cleanpath

// Constructor
Firnplayer::Player::Player()
{
  ConfigDir = cleanpath(HomePath() + "/.firnplayer");
  ConfigFile = cleanpath(ConfigDir + "/Configuration.json");
  TrackInfoFile = cleanpath(ConfigDir + "/TrackInfo.json");
  
  ThePlayer = this;

  // Check if Config path exists and make if not.
  if(!FileExists(ConfigDir))
  {
    std::printf("Config folder %s does not exist, creating.\n", ConfigDir.c_str());
    boost::filesystem::create_directory(ConfigDir);
    if(!FileExists(ConfigDir))
    {
      FatalErrorString = StringPrintf("Could not create directory %s, aborting\n", ConfigDir.c_str());
    }
  }

  // Load and sanitize config file.
  if(FileExists(ConfigFile))
  {
    std::printf("Reading Config\n");
    LoadJson(ConfigFile, Options);
  }
  SanitizeConfig();

  ActiveViewPort = ACTIVE_ARTISTS;

  // Set the frame colours
  ArtistView.SetFrameColPair(COLPAIR_FRAME);
  TrackView.SetFrameColPair(COLPAIR_FRAME);
  QueueView.SetFrameColPair(COLPAIR_FRAME);
  PlaylistView.SetFrameColPair(COLPAIR_FRAME);

  // Load track info if it exists.
  std::string TrackDBPath = cleanpath(ConfigDir + "/TrackInfo.Json");
  if(FileExists(TrackDBPath))
  {
    std::printf("Loading Track Info\n");
    if(!LoadJson(TrackDBPath, TrackList))  // No queue lock.  No other threads should be running.
    {
      std::printf("Stored track info file corrupt, starting empty.\n");
    }
    else
    {
      Threads["Sorter"] = std::thread(Sortfunction, std::ref(Artists), std::ref(ArtistsQueue), 
                                      std::ref(TrackList), std::ref(TrackListQueue));
    }
  }
  Running = 1;
}
开发者ID:firngrod,项目名称:firnplayer,代码行数:53,代码来源:Player.cpp

示例11: os_version_string

std::string os_version_string() {
#if defined ( __linux__ )
  File info("/proc/sys/kernel", "osrelease");
  if (info.Exists()) {
    FILE *kernel_file;
    struct k_version { unsigned major, minor, update, iteration; };
    struct k_version k_version;
    kernel_file = fopen("/proc/sys/kernel/osrelease","r");
    fscanf(kernel_file,"%u%*c%u%*c%u%*c%u",
	   &k_version.major,
	   &k_version.minor,
	   &k_version.update,
	   &k_version.iteration);
    fclose(kernel_file);
    char osrelease[100];
    sprintf(osrelease,"%u.%u.%u-%u", k_version.major,
	    k_version.minor,
	    k_version.update,
	    k_version.iteration);
    info.Close();
    return StringPrintf("Linux %s", osrelease);
  }
  return std::string("Linux");
#elif defined ( __APPLE__ )
  return string("MacOSX"); // StringPrintf("%s %s", GetOSNameString(), GetMacVersionString());
#elif defined(__OS2__)
  return string("OS/2");
#elif defined(__FreeBSD__)
  return string("FreeBSD");
#elif defined(__OpenBSD__)
  return string("OpenBSD");
#elif defined(__NetBSD__)
  return string("NetBSD");
#elif defined(BSD)
  return string("BSD");
#elif defined(__solaris__)
  return string("Solaris");
#elif defined(__sun__)
  return string("SunOS");
#elif defined(__gnu__)
  return string("GNU/Hurd");
#elif defined(__QNX__)
  return string("QNX");
#elif defined(__unix__)
  return string("UNIX");
#elif defined(__HAIKU__)
  return string("Haiku");
#endif
  return string("UNKNOWN OS");
}
开发者ID:TellarHK,项目名称:wwiv,代码行数:50,代码来源:os_unix.cpp

示例12: getString

String UrlParse::getString() const {
  String ret;
  ret.printf("%s://%s", protocol.vs(), hostname.vs());
  if (port != 80 && port != 0) ret.cat(StringPrintf(":%d", port));
  if (!path.isempty()) {
    if (path.firstChar() != '/') ret.cat("/");
    ret.cat(path);
  }
  if (!resource.isempty()) {
    if (resource.firstChar() != '/') ret.cat("/");
    ret.cat(resource);
  }
  return ret;
}
开发者ID:bizzehdee,项目名称:wasabi,代码行数:14,代码来源:urlparse.cpp

示例13: handle_sub_add_drop_resp

bool handle_sub_add_drop_resp(Context& context, Packet& p, const std::string& add_or_drop) {
  // We want to stop at the 1st \0
  string subname = p.text.c_str();
  StringTrimEnd(&subname);

  auto b = p.text.begin();
  while (b != p.text.end() && *b != '\0') { b++; }
  if (b == p.text.end()) {
    LOG(INFO) << "Unable to determine code from add_drop response.";
    return false;
  } // NULL
  b++;
  if (b == p.text.end()) {
    LOG(INFO) << "Unable to determine code from add_drop response.";
    return false;
  }

  LOG(INFO) << "Processed " << add_or_drop << " response from system @" << p.nh.fromsys << " to subtype: " << subname;

  char code = *b++;
  string code_string = SubAddDropResponseMessage(static_cast<uint8_t>(code));
  string message_text = string(b, p.text.end());
  net_header_rec nh = {};

  string title = StringPrintf("WWIV AreaFix (%s) Response for subtype '%s'", context.net.name, subname.c_str());
  string byname = StringPrintf("WWIV AreaFix (%s) @%u", context.net.name, p.nh.fromsys);
  string body = StringPrintf("SubType '%s', (%s) Response: '%s'\r\n%s\r\n", 
    subname.c_str(), add_or_drop.c_str(), code_string.c_str(), message_text.c_str());

  nh.touser = 1;
  nh.fromuser = std::numeric_limits<uint16_t>::max();
  nh.main_type = main_type_email;
  nh.daten = wwiv::sdk::time_t_to_daten(time(nullptr));

  const string filename = create_pend(context.net.dir, true, static_cast<char>('0' + context.network_number));
  return send_network_email(filename, context.net, nh, {}, body, byname, title);
}
开发者ID:wwivbbs,项目名称:wwiv,代码行数:37,代码来源:subs.cpp

示例14: bindtextdomain

bool NotificationBackendLibnotify::init()
{
    bindtextdomain (GETTEXT_PACKAGE, SYNCEVOLUTION_LOCALEDIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);

#ifdef NOTIFY_COMPATIBILITY
    void *dlhandle = NULL;
    int i;
    for (i = 1; i <= 4; i++) {
        dlhandle = dlopen(StringPrintf("libnotify.so.%d", i).c_str(), RTLD_LAZY|RTLD_GLOBAL);
        if (!dlhandle) {
            SE_LOG_DEBUG(NULL, NULL, "failed to load libnotify.so.%d: %s", i, dlerror());
        } else {
            break;
        }
    }
    if (!dlhandle) {
        return false;
    }

#define LOOKUP(_x) ((_x = reinterpret_cast<typeof(_x)>(dlsym(dlhandle, #_x))) || \
                    NotFound(#_x))

    if (!LOOKUP(notify_init) ||
        !LOOKUP(notify_get_server_caps) ||
        !LOOKUP(notify_notification_new) ||
        !LOOKUP(notify_notification_add_action) ||
        !LOOKUP(notify_notification_clear_actions) ||
        !LOOKUP(notify_notification_close) ||
        !LOOKUP(notify_notification_show)) {
        return false;
    }
    SE_LOG_DEBUG(NULL, NULL, "using libnotify.so.%d", i);
#endif

    m_initialized = notify_init("SyncEvolution");
    if(m_initialized) {
        GStringListFreeCXX list(notify_get_server_caps());
        BOOST_FOREACH (const char *cap, list) {
            if(boost::iequals(cap, "actions")) {
                m_acceptsActions = true;
            }
        }
        return true;
    }

    return false;
}
开发者ID:mikmakmuk,项目名称:syncevolution_n9,代码行数:49,代码来源:notification-backend-libnotify.cpp

示例15: getOAuth2Bearer

    virtual std::string getOAuth2Bearer(const PasswordUpdateCallback &passwordUpdateCallback)
    {
        SE_LOG_DEBUG(NULL, "retrieving OAuth2 token");

        if (!m_accessToken.empty() && !m_invalidateCache) {
            return m_accessToken;
        }

        // Retry login if even the refreshed token failed.
        g_hash_table_insert(m_sessionData, g_strdup("ForceTokenRefresh"),
                            g_variant_ref_sink(g_variant_new_boolean(m_invalidateCache)));

        // We get assigned a plain pointer to an instance that we'll own,
        // so we have to use the "steal" variant to enable that assignment.
        GVariantStealCXX resultDataVar;
        GErrorCXX gerror;
        GVariantCXX sessionDataVar(HashTable2Variant(m_sessionData));
        PlainGStr buffer(g_variant_print(sessionDataVar, true));
        SE_LOG_DEBUG(NULL, "asking for OAuth2 token with method %s, mechanism %s and parameters %s",
                     signon_auth_session_get_method(m_authSession),
                     m_mechanism.c_str(),
                     buffer.get());

#define signon_auth_session_process_async_finish signon_auth_session_process_finish
        SYNCEVO_GLIB_CALL_SYNC(resultDataVar, gerror, signon_auth_session_process_async,
                               m_authSession, sessionDataVar, m_mechanism.c_str(), NULL);
        buffer.reset(resultDataVar ? g_variant_print(resultDataVar, true) : NULL);
        SE_LOG_DEBUG(NULL, "OAuth2 token result: %s, %s",
                     buffer.get() ? buffer.get() : "<<null>>",
                     gerror ? gerror->message : "???");
        if (!resultDataVar || gerror) {
            SE_THROW_EXCEPTION_STATUS(StatusException,
                                      StringPrintf("could not obtain OAuth2 token: %s", gerror ? gerror->message : "???"),
                                      STATUS_FORBIDDEN);
        }
        GHashTableCXX resultData(Variant2HashTable(resultDataVar));
        GVariant *tokenVar = static_cast<GVariant *>(g_hash_table_lookup(resultData, (gpointer)"AccessToken"));
        if (!tokenVar) {
            SE_THROW("no AccessToken in OAuth2 response");
        }
        std::string newToken = g_variant_get_string(tokenVar, NULL);
        if (newToken.empty()) {
            SE_THROW("AccessToken did not contain a string value");
        } else if (m_invalidateCache && newToken == m_accessToken) {
            SE_THROW("Got the same invalid AccessToken");
        }
        m_accessToken = newToken;
        return m_accessToken;
    }
开发者ID:freedesktop-unofficial-mirror,项目名称:SyncEvolution__syncevolution,代码行数:49,代码来源:signon.cpp


注:本文中的StringPrintf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。