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


C++ AnyString类代码示例

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


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

示例1:

	File::File(const AnyString& filePath):
		pFormat(nullptr)
	{
		if (filePath.empty())
			return;

		# if LIBAVFORMAT_VERSION_MAJOR < 53
		if (::av_open_input_file(&pFormat, filePath.c_str(), nullptr, 0, nullptr))
		# else
		if (::avformat_open_input(&pFormat, filePath.c_str(), nullptr, nullptr))
		# endif // LIBAVFORMAT_VERSION_MAJOR < 53
		{
			pFormat = nullptr;
			return;
		}

		// After opening, we must search for the stream information because not
		// all formats will have it in stream headers (eg. system MPEG streams)
		# if LIBAVFORMAT_VERSION_MAJOR < 53
		if (::av_find_stream_info(pFormat) < 0)
		# else
		if (::avformat_find_stream_info(pFormat, nullptr) < 0)
		# endif // LIBAVFORMAT_VERSION_MAJOR < 53
		{
			# if LIBAVFORMAT_VERSION_MAJOR < 53
			::av_close_input_file(pFormat);
			# else
			::avformat_close_input(&pFormat);
			# endif // LIBAVFORMAT_VERSION_MAJOR < 53
			pFormat = nullptr;
			return;
		}
	}
开发者ID:MAPJe71,项目名称:libyuni,代码行数:33,代码来源:file.cpp

示例2: truncate

DBI::Error Transaction::truncate(const AnyString& tablename)
{
    if (YUNI_UNLIKELY(not IsValidIdentifier(tablename)))
        return errInvalidIdentifier;

    assert(!(!pChannel));

    // the adapter
    ::yn_dbi_adapter& adapter = pChannel->adapter;

    // The DBI interface should provide the most appropriate way for
    // truncating a table (autoincrement / cascade...)
    if (YUNI_LIKELY(adapter.truncate))
    {
        return (DBI::Error) adapter.truncate(adapter.dbh, tablename.c_str(), tablename.size());
    }
    else
    {
        // Fallback to a failsafe method
        // -- stmt << "TRUNCATE " << tablename << ';';
        // The SQL command Truncate is not supported by all databases. `DELETE FROM`
        // is not  the most efficient way for truncating a table
        // but it should work almost everywhere
        String stmt;
        stmt << "DELETE FROM " << tablename << ';';
        return perform(stmt);
    }
}
开发者ID:ollie314,项目名称:libyuni,代码行数:28,代码来源:transaction.cpp

示例3: prepare

Cursor Transaction::prepare(const AnyString& stmt)
{
    assert(!(!pChannel));

    // the adapter
    ::yn_dbi_adapter& adapter = pChannel->adapter;

    if (YUNI_UNLIKELY(nullHandle == pTxHandle))
    {
        if (errNone != pChannel->begin(pTxHandle))
            return Cursor(adapter, nullptr);
    }

    // query handle
    void* handle = nullptr;

    if (YUNI_LIKELY(not stmt.empty() and adapter.dbh))
    {
        assert(adapter.query_new != NULL  and "invalid adapter query_new");
        assert(adapter.query_ref_acquire != NULL and "invalid adapter query_ref_acquire");
        assert(adapter.query_ref_release != NULL and "invalid adapter query_ref_release");

        adapter.query_new(&handle, adapter.dbh, stmt.c_str(), stmt.size());
    }

    return Cursor(adapter, handle);
}
开发者ID:ollie314,项目名称:libyuni,代码行数:27,代码来源:transaction.cpp

示例4:

	int Luhn::Mod10(const AnyString& s)
	{
		// The string must have at least one char
		if (s.size() > 1)
		{
			// The algorithm :
			// 1 - Counting from the check digit, which is the rightmost, and moving
			//     left, double the value of every second digit.
			// 2 - Sum the digits of the products together with the undoubled digits
			//     from the original number.
			// 3 - If the total ends in 0 (put another way, if the total modulo 10 is
			//     congruent to 0), then the number is valid according to the Luhn formula
			//
			static const int prefetch[] = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9};

			int sum = 0;
			bool alternate = true;

			const AnyString::iterator end = s.end();
			// For each char
			for (AnyString::iterator i = s.begin(); end != i; ++i)
			{
				// Each char in the string must be a digit
				if (!String::IsDigit(i.value()))
					return false;
				// The `real` digit
				int n = i.value() - '0';
				// Computing the sum
				sum += (alternate = !alternate) ? prefetch[n] : n;
			}
			return sum % 10;
		}
		return -1;
	}
开发者ID:UNIVERSAL-IT-SYSTEMS,项目名称:libyuni,代码行数:34,代码来源:luhn.cpp

示例5: Size

	bool Size(const AnyString& filename, uint64& value)
	{
		struct stat results;
		if (not filename.empty() && stat(filename.c_str(), &results) == 0)
		{
			value = (uint64) results.st_size;
			return true;
		}
		value = 0u;
		return false;
	}
开发者ID:srpgilles,项目名称:pict_stock,代码行数:11,代码来源:file.cpp

示例6: TypeOf

	Yuni::IO::NodeType TypeOf(const AnyString& filename)
	{
		if (filename.empty())
			return Yuni::IO::typeUnknown;

		# ifdef YUNI_OS_WINDOWS
		const char* p = filename.c_str();
		unsigned int len = filename.size();
		if (p[len - 1] == '\\' or p[len - 1] == '/')
		{
			if (!--len)
			{
				# ifdef YUNI_OS_WINDOWS
				return Yuni::IO::typeUnknown;
				# else
				// On Unixes, `/` is a valid folder
				return Yuni::IO::typeFolder;
				# endif
			}
		}

		// Driver letters
		if (len == 2 and p[1] == ':')
			return Yuni::IO::typeFolder;

		String  norm;
		Yuni::IO::Normalize(norm, AnyString(p, len));
		// Conversion into wchar_t
		Private::WString<true> wstr(norm);
		if (wstr.empty())
			return Yuni::IO::typeUnknown;

		WIN32_FILE_ATTRIBUTE_DATA infoFile;
		if (!GetFileAttributesExW(wstr.c_str(), GetFileExInfoStandard, &infoFile))
			return Yuni::IO::typeUnknown;

		return ((infoFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
			? Yuni::IO::typeFolder
			: Yuni::IO::typeFile;

		# else // WINDOWS

		struct stat s;
		if (stat(filename.c_str(), &s) != 0)
			return Yuni::IO::typeUnknown;

		return (S_ISDIR(s.st_mode))
			? Yuni::IO::typeFolder
			: Yuni::IO::typeFile;
		# endif
	}
开发者ID:MAPJe71,项目名称:libyuni,代码行数:51,代码来源:exists.cpp

示例7: Exception

	PathFormat::PathFormat(LoggingFacility& logs, const AnyString& format)
		: logs(logs),
		  pFolderPart(nullptr),
		  pFilePart(nullptr)
	{
		if (format.contains('('))
			throw GenericTools::Exception("Format shouldn't include any parenthesis");

		{
			String folderName, fileName;

			// Split the path and the filename
			IO::ExtractFilePath(folderName, format, false);

			if (folderName.empty())
				fileName = format;
			else
			{
				IO::ExtractFileName(fileName, format, false);
				if (IO::Separator != '/')
				{
					if (IO::Separator == '\\')
						folderName.replace("/", "\\\\");
					else
						folderName.replace('/', IO::Separator);
				}
				logs.notice("Folder = ") << folderName;
				pFolderPart = new Private::PathFormatHelper(logs, folderName);
			}

			logs.notice("File = ") << fileName;
			pFilePart = new Private::PathFormatHelper(logs, fileName);
		}
	}
开发者ID:srpgilles,项目名称:pict_stock,代码行数:34,代码来源:path_format.cpp

示例8: TypeOf

	NodeType TypeOf(const AnyString& filename, bool followSymLink)
	{
		yuint64 size; // useless
		yint64 lastModified;
		return (YUNI_LIKELY(not filename.empty()))
			? Stat(filename, size, lastModified, followSymLink) : IO::typeUnknown;
	}
开发者ID:UNIVERSAL-IT-SYSTEMS,项目名称:libyuni,代码行数:7,代码来源:exists.cpp

示例9: FetchFileStatus

	NodeType FetchFileStatus(const AnyString& filename, yuint64& size, yint64& lastModified, bool followSymLink)
	{
		size = 0u;
		lastModified = 0;
		return (YUNI_LIKELY(not filename.empty()))
			? Stat(filename, size, lastModified, followSymLink) : IO::typeUnknown;
	}
开发者ID:UNIVERSAL-IT-SYSTEMS,项目名称:libyuni,代码行数:7,代码来源:exists.cpp

示例10: loadFromMemory

	bool VertexShader::loadFromMemory(const AnyString& source)
	{
		if (pID == invalidID)
			pID = ::glCreateShader(GL_VERTEX_SHADER);
		const char* data = source.data();
		::glShaderSource(pID, 1, &data, nullptr);
		::glCompileShader(pID);
		return GLTestError("VertexShader::loadFromMemory");
	}
开发者ID:MAPJe71,项目名称:libyuni,代码行数:9,代码来源:shader.cpp

示例11: Delete

	Yuni::IO::Error Delete(const AnyString& filename)
	{
		// DeleteFile is actually a macro and will be replaced by DeleteFileW
		// with Visual Studio. Consequently we can not use the word DeleteFile.....

		if (filename.empty())
			return Yuni::IO::errUnknown;

		# ifndef YUNI_OS_WINDOWS

		return (unlink(filename.c_str()))
			? Yuni::IO::errUnknown
			: Yuni::IO::errNone;

		# else

		const char* const p = filename.c_str();
		uint len = filename.size();

		if (p[len - 1] == '\\' or p[len - 1] == '/')
			--len;

		// Driver letters
		if (len == 2 and p[1] == ':')
			return Yuni::IO::errBadFilename;

		String norm;
		Yuni::IO::Normalize(norm, AnyString(p, len));

		// Conversion into wchar_t
		WString wstr(norm, true);
		if (wstr.empty())
			return Yuni::IO::errUnknown;
		wstr.replace('/', '\\');

		return (DeleteFileW(wstr.c_str()))
			? Yuni::IO::errNone
			: Yuni::IO::errUnknown;
		# endif
	}
开发者ID:libyuni,项目名称:libyuni,代码行数:40,代码来源:file.cpp

示例12: Create

	bool Create(const AnyString& path, uint mode)
	{
		if (not path.empty() and not Yuni::IO::Exists(path))
		{
			# ifdef YUNI_OS_WINDOWS
			// `mode` is not used on Windows
			(void) mode;
			return WindowsMake(path);
			# else
			return UnixMake(path, mode);
			# endif
		}
		return true;
	}
开发者ID:MAPJe71,项目名称:libyuni,代码行数:14,代码来源:create.cpp

示例13: perform

DBI::Error Transaction::perform(const AnyString& script)
{
    assert(!(!pChannel));

    // the adapter
    ::yn_dbi_adapter& adapter = pChannel->adapter;
    assert(adapter.query_exec != NULL);

    if (YUNI_LIKELY(nullHandle != pTxHandle))
    {
        return (DBI::Error) adapter.query_exec(adapter.dbh, script.c_str(), script.size());
    }
    else
    {
        // start a new transaction
        DBI::Error error = pChannel->begin(pTxHandle);

        if (YUNI_LIKELY(error == errNone))
            error = (DBI::Error) adapter.query_exec(adapter.dbh, script.c_str(), script.size());

        return error;
    }
}
开发者ID:ollie314,项目名称:libyuni,代码行数:23,代码来源:transaction.cpp

示例14: UnixMake

	static bool UnixMake(const AnyString& path, uint mode)
	{
		const uint len = path.size();
		char* buffer = new char[len + 1];
		YUNI_MEMCPY(buffer, len, path.c_str(), len);
		buffer[len] = '\0';
		char* pt = buffer;
		char tmp;

		do
		{
			if ('\\' == *pt or '/' == *pt or '\0' == *pt)
			{
				tmp = *pt;
				*pt = '\0';
				if ('\0' != buffer[0] and '\0' != buffer[1] and '\0' != buffer[2])
				{
					if (mkdir(buffer, static_cast<mode_t>(mode)) < 0)
					{
						if (errno != EEXIST and errno != EISDIR and errno != ENOSYS)
						{
							delete[] buffer;
							return false;
						}
					}
				}
				if ('\0' == tmp)
					break;
				*pt = tmp;
			}
			++pt;
		}
		while (true);

		delete[] buffer;
		return true;
	}
开发者ID:MAPJe71,项目名称:libyuni,代码行数:37,代码来源:create.cpp

示例15: LastModificationTime

	sint64 LastModificationTime(const AnyString& filename)
	{
		# ifdef YUNI_OS_WINDOWS

		Private::WString<> wfilenm(filename);
		if (wfilenm.empty())
			return 0;
		HANDLE hFile = CreateFileW(wfilenm.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL,
			OPEN_EXISTING, 0, NULL);
		if (hFile == INVALID_HANDLE_VALUE)
			return 0;

		FILETIME ftCreate, ftAccess, ftWrite;
		// Retrieve the file times for the file.
		if (GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite))
		{
			CloseHandle(hFile);

			LARGE_INTEGER date, adjust;
			date.HighPart = ftWrite.dwHighDateTime;
			date.LowPart = ftWrite.dwLowDateTime;

			// 100-nanoseconds = milliseconds * 10000
			adjust.QuadPart = 11644473600000 * 10000;

			// removes the diff between 1970 and 1601
			date.QuadPart -= adjust.QuadPart;

			// converts back from 100-nanoseconds to seconds
			return date.QuadPart / 10000000;
		}

		CloseHandle(hFile);
		return 0;

		# else // UNIX

		struct stat st;
		if (!stat(filename.c_str(), &st))
			return st.st_mtime;
		return 0;

		# endif
	}
开发者ID:srpgilles,项目名称:pict_stock,代码行数:44,代码来源:file.cpp


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