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


C++ string::back方法代码示例

本文整理汇总了C++中std::string::back方法的典型用法代码示例。如果您正苦于以下问题:C++ string::back方法的具体用法?C++ string::back怎么用?C++ string::back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::string的用法示例。


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

示例1: skey

void IniSetting::ParserCallback::onPopEntry(
    const std::string &key,
    const std::string &value,
    const std::string &offset,
    void *arg) {
  Variant *arr = (Variant*)arg;
  forceToArray(*arr);

  bool oEmpty = offset.empty();
  // Substitution copy or symlink
  // Offset come in like: hhvm.a.b\0c\[email protected]
  // Check for `\0` because it is possible, although unlikely, to have
  // something like hhvm.a.b[[email protected]]. Thus we wouldn't want to make a substitution.
  if (!oEmpty && (offset.size() == 1 || offset[offset.size() - 2] == '\0') &&
      (offset.back() == '@' || offset.back() == ':')) {
    makeSettingSub(key, offset, value, *arr);
  } else {                                 // Normal array value
    String skey(key);
    auto& hash = arr->toArrRef().lvalAt(skey);
    forceToArray(hash);
    if (!oEmpty) {                         // a[b]
      makeArray(hash, offset, value);
    } else {                               // a[]
      hash.toArrRef().append(value);
    }
  }
}
开发者ID:Riposati,项目名称:hhvm,代码行数:27,代码来源:ini-setting.cpp

示例2: Validate

bool CreditCard::Validate(std::string creditCardNumber)
{
    unsigned int sum=0;
    bool toggle=true;
    unsigned int otherCheckDigit=creditCardNumber.back() - '0';
    unsigned int myCheckDigit=0;

    creditCardNumber.pop_back();

    while(!creditCardNumber.empty())
    {
        unsigned int temp=creditCardNumber.back() - '0'; //saves last digit

        if (toggle)
        {
            temp= temp*2;

            if (temp>=10)
                temp=temp-9;
        }

        sum=sum+temp;

        toggle=!toggle;
        creditCardNumber.pop_back(); //deletes last digit
    }

    myCheckDigit= (sum*9)%10;

    return (otherCheckDigit==myCheckDigit);
}
开发者ID:Secret-Asian-Man,项目名称:cs8,代码行数:31,代码来源:creditcard.cpp

示例3: toNum

long long toNum(std::string str, int type = 0)
{
	int len = str.length();
	long long ret = 0;
	if (len < 1)
		return 0;
	if (canBeNum(str) == false)
		return 0;
	std::stringstream ss;
	bool negative = false;
	if (str.front() == '-')
	{
		str.erase(0, 1);
		negative = true;
		len--;
	}
	else if (str.front() == '+')
	{
		str.erase(0, 1);
		len--;
	}
	switch (type)
	{
		case 0:
			if (len == 0)
				return 0;
			if (str.back() == 'h' || str.back() == 'H')
			{
				str.erase(len - 1, 1);
				ss << std::hex << str;
				ss >> ret;
			}
			else if (str.front() == '0' && len > 1)
开发者ID:xy12423,项目名称:xy_DCPU16_Emulator,代码行数:33,代码来源:function.hpp

示例4: set_workspace

	void basic_configuration::set_workspace(std::string path)
	{
		if (path.back() != '/' && path.back() != '\\')
			path.push_back('/');

		pimpl->workspace_path = path;
	}
开发者ID:Lewerow,项目名称:DetailIdentifier,代码行数:7,代码来源:basic_configuration.cpp

示例5: parse_obj

bool ConfigReader::parse_obj(const std::string &key, std::string &obj,
		std::string &err)
{
	std::vector<std::string> items;
	std::string okey, oval;
	std::unordered_map<std::string, std::string> map;
	size_t ind;

	/* remove surrounding braces and whitespace */
	obj = obj.substr(1);
	remove_leading(obj);
	while (obj.back() != '}')
		obj.pop_back();
	obj.pop_back();
	while (isspace(obj.back()))
		obj.pop_back();

	utils::split(obj, '\n', items);

	for (std::string s : items) {
		if ((ind = s.find('=')) == std::string::npos) {
			err = "unrecognized token in list -- ";
			for (ind = 0; !isspace(s[ind]); ++ind)
				err += s[ind];
			return false;
		}
		okey = s.substr(0, ind);
		while (isspace(okey.back()))
			okey.pop_back();
		oval = parse_string(s);
		map[okey] = oval;
	}
	olistmap[key].emplace_back(map);
	return true;
}
开发者ID:frolv,项目名称:lynxbot,代码行数:35,代码来源:config.cpp

示例6: downloadMedia

void bebopftp::downloadMedia(std::string bebop_ip, std::string download_to, bool erase)
{
    if(download_to.back() != '/' && download_to.back() != '\\')
    {
        download_to.append("/");
    }

    nsFTP::CFTPClient ftpClient;
    nsFTP::CLogonInfo logonInfo(bebop_ip);

    ftpClient.Login(logonInfo);
    nsFTP::TFTPFileStatusShPtrVec list;
    ftpClient.List(BEBOP_MEDIA_LOCATION, list);

    for(nsFTP::TFTPFileStatusShPtrVec::iterator it=list.begin(); it!=list.end(); it++)
    {
        std::cout << "Downloading " << (*it)->Name() << " into " << download_to << std::endl;
        ftpClient.DownloadFile(BEBOP_MEDIA_LOCATION + (*it)->Name(), download_to + (*it)->Name());
        if(erase)
        {
            ftpClient.Delete(BEBOP_MEDIA_LOCATION + (*it)->Name());
        }
    }

    ftpClient.Logout();

    std::cout << "Done." << std::endl;
}
开发者ID:Jlaird,项目名称:AutoFlight_v1,代码行数:28,代码来源:bebopftp.cpp

示例7: GetLastPathComponent

 /*
  *  GetLastPathComponent
  *      @path: Path to get the last component from
  *      @return: Returns the last path component position in the string
  */
 inline std::string::size_type GetLastPathComponent(std::string path)
 {
     // Remove any slash at the end of the string, so our finding can be safe
     while(path.back() == '/' || path.back() == '\\') path.pop_back();
     // Do the search
     size_t pos = path.find_last_of("/\\");
     return (pos == path.npos? 0 : pos + 1);
 }
开发者ID:Whitetigerswt,项目名称:sa-modloader,代码行数:13,代码来源:modloader_util_path.hpp

示例8: getFullPath

std::string getFullPath(const std::string& parentDir, const std::string& name) {
	std::string full = parentDir;
	if (parentDir.back() != '/' && parentDir.back() != '\\') {
		return parentDir + "\\" + name;
	} else {
		return parentDir + name;
	}
}
开发者ID:flexme,项目名称:svnplugin,代码行数:8,代码来源:fileutil.cpp

示例9: ensure_trailing_separators

static void ensure_trailing_separators(std::string& local_path, std::string& remote_path) {
    if (!adb_is_separator(local_path.back())) {
        local_path.push_back(OS_PATH_SEPARATOR);
    }
    if (remote_path.back() != '/') {
        remote_path.push_back('/');
    }
}
开发者ID:android,项目名称:platform_system_core,代码行数:8,代码来源:file_sync_client.cpp

示例10: normalize

void Talkbot::normalize(std::string& sentence) const
{
	if(not sentence.empty())
	{
		if(std::islower(sentence[0]))
			sentence[0] = std::toupper(sentence[0]);
		if(sentence.back() != '.' and sentence.back() != '!' and sentence.back() != '?')
			sentence.push_back('.');
	}
}
开发者ID:TheoVerhelst,项目名称:Talkbot,代码行数:10,代码来源:Talkbot.cpp

示例11: NormalizePath

 /*
  *  NormalizePath
  *      Normalizates a path string, so for example:
  *          "somefolder/something" will output "somefolder\\something"
  *          "SOMEfoldER/something/" will output "somefolder\\something"
  *          "somefolder\\something" will output "somefolder\\something"
  *          etc
  */
 inline std::string NormalizePath(std::string path)
 {
     
     std::replace(path.begin(), path.end(), '/', '\\');  // Replace all '/' with '\\'
     tolower(path);                                      // tolower the strings (Windows paths are case insensitive)
     while(path.back() == '/' || path.back() == '\\')    // We don't want a slash at the end of the folder path
         path.pop_back();                                // ..
     trim(path);                                         // Trim the string...
     return path;
 }
开发者ID:Whitetigerswt,项目名称:sa-modloader,代码行数:18,代码来源:modloader_util_path.hpp

示例12: joinPath

LODEN_CORE_EXPORT std::string joinPath(const std::string &path1, const std::string &path2)
{
    if (path1.empty())
        return path2;
    if (isAbsolutePath(path2))
        return path2;
    if(path1.back() == '/' || path1.back() == '\\')
        return path1 + path2;
    return path1 + "/" + path2;
}
开发者ID:ronsaldo,项目名称:loden,代码行数:10,代码来源:FileSystem.cpp

示例13: receive

bool GenericSocket::receive(int timeout, std::string &reply, int expected, bool raw)
{
	int length;
	int run;
	struct pollfd pfd = { .fd = fd, .events = POLLIN | POLLERR | POLLHUP, .revents = 0 };
	char buffer[8192];

	reply.clear();

	for(run = 8; run > 0; run--)
	{
		if(poll(&pfd, 1, timeout) != 1)
			return(false);

		if(pfd.revents & (POLLERR | POLLHUP))
			return(false);

		if((length = read(fd, buffer, sizeof(buffer) - 1)) < 0)
			return(false);

		if(length == 0)
		{
			if(reply.length() == 0) // ignore terminating empty udp packed from previous output
				continue;
			else
				break;
		}

		reply.append(buffer, (size_t)length);

		if((expected > 0) && (expected > length))
			expected -= length;
		else
			break;
	}

	if(reply.back() == '\n')
		reply.pop_back();

	if(!raw && (reply.back() == '\r'))
		reply.pop_back();

	return(true);
}

static std::string sha_hash_to_text(const unsigned char *hash)
{
	unsigned int current;
	std::stringstream hash_string;

	for(current = 0; current < SHA_DIGEST_LENGTH; current++)
		hash_string << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)hash[current];

	return(hash_string.str());
}
开发者ID:eriksl,项目名称:esp8266-universal-io-bridge,代码行数:55,代码来源:espflash.cpp

示例14: SplitGltfAttribute

void SplitGltfAttribute(std::string attribute, std::string *semanticName, DWORD *semanticIndex)
{
    *semanticIndex = 0;

    if (isdigit(attribute.back()))
    {
        *semanticIndex = attribute.back() - '0';

        attribute.pop_back();
        if (attribute.back() == '_')
            attribute.pop_back();
    }

    *semanticName = attribute;
}
开发者ID:GPUOpen-Tools,项目名称:Compressonator,代码行数:15,代码来源:glTFHelpers.cpp

示例15: attributeHasAnnotation

bool attributeHasAnnotation(
    const std::string& annotation,
    const std::string& attributeName,
    std::string* comment) {
    // Unqualified actions must compare directly e.g. we don't want to return a match for 
    // for 'CAPA:suppress' when the annotation is 'CAPA::suppress[foo]'
    if(attributeName.find('[') == std::string::npos) {
        return attributeName == annotation;
    }
    
    // Otherwise, check if the attributeName is a prefix of the annotation
    // We need to check prefix and not equality in case there's a comment
    if(annotation.length() < attributeName.length() ||
        !std::equal(attributeName.begin(), attributeName.end(), annotation.begin())) {
        return false;
    }
    // The attributes match.
    // Try to pick out a comment if we need to
    if(comment != nullptr) {
        const auto commentStart = annotation.find('[', attributeName.length());
    
        if(commentStart != std::string::npos && annotation.back() == ']') {
            *comment =
               annotation.substr(commentStart + 1, annotation.length() - commentStart - 2);
        }
    }
    return true;
}
开发者ID:Jhana1,项目名称:CAPA,代码行数:28,代码来源:AttributeHelper.cpp


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