本文整理汇总了C++中string_type::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ string_type::empty方法的具体用法?C++ string_type::empty怎么用?C++ string_type::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string_type
的用法示例。
在下文中一共展示了string_type::empty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: import
void import(const base_url &n) {
if (protocol.empty() && !n.protocol.empty())
protocol = n.protocol;
if (host.empty() && !n.host.empty())
host = n.host;
if (port == 0 && n.port != 0)
port = n.port;
if (path.empty() && !n.path.empty())
path = n.path;
if (query.empty() && !n.query.empty())
query = n.query;
}
示例2: equals
static bool equals(const string_type& str1, const string_type& str2) {
if(str1.size() != str2.size()) {
return false;
} else if(str1.empty() && str2.empty()) {
return true;
} else {
return std::equal(
str1.begin(),
str1.end(),
str2.begin()
);
}
}
示例3: DWORD
BOOST_LOG_EXPORT void basic_event_log_backend< CharT >::construct(
boost::log::aux::universal_path const& message_file_name,
string_type const& target,
string_type const& log_name,
string_type const& source_name,
event_log::registration_mode reg_mode)
{
if (reg_mode != event_log::never)
{
aux::registry_params< char_type > reg_params;
string_type file_name;
log::aux::code_convert(message_file_name.string(), file_name);
reg_params.event_message_file = file_name;
reg_params.types_supported = DWORD(
EVENTLOG_SUCCESS |
EVENTLOG_INFORMATION_TYPE |
EVENTLOG_WARNING_TYPE |
EVENTLOG_ERROR_TYPE);
aux::init_event_log_registry(log_name, source_name, reg_mode == event_log::forced, reg_params);
}
std::auto_ptr< implementation > p(new implementation());
const char_type* target_unc = NULL;
if (!target.empty())
target_unc = target.c_str();
HANDLE hSource = register_event_source(target_unc, source_name.c_str());
if (!hSource)
BOOST_LOG_THROW_DESCR(system_error, "Could not register event source");
p->m_SourceHandle = hSource;
m_pImpl = p.release();
}
示例4: operator
void operator()(const Char* data)
{
if (exe.empty())
exe = data;
else
args.push_back(data);
}
示例5: get_name_
void get_name_(FwdIter &begin, FwdIter end, string_type &name)
{
this->eat_ws_(begin, end);
for(name.clear(); begin != end && this->is_alnum_(*begin); ++begin)
{
name.push_back(*begin);
}
this->eat_ws_(begin, end);
detail::ensure(!name.empty(), regex_constants::error_paren, "incomplete extension");
}
示例6: comment
void comment(const string_type& s) {
adaptor_statistics.comment(s);
if (s.empty())
out << "c";
else
if (boost::algorithm::is_space()(s[0]))
out << "c" << s;
else
out << "c " << s;
out << "\n";
}
示例7: start
void start(basic_session<T>& sesh, string_type const& ssid = "")
{
if (!sesh.loaded() && sesh.id().empty())
{
if (!ssid.empty()) {
sesh.id(ssid);
load(sesh);
} else {
sesh.id(make_session_id());
sesh.loaded(true);
}
}
}
示例8: endTag
// Close tag (may be with closing all of its children)
void XmlStream::endTag(const string_type& tag)
{
bool brk = false;
while (tags.size() > 0 && !brk) {
if (stateNone == state) {
startTagging();
s << "</" << tags.top() << '>';
endTagging();
}
else {
closeTagStart(true);
state = stateNone;
}
brk = tag.empty() || tag == tags.top();
tags.pop();
}
}
示例9: raw_request
void raw_request( const string_type& method, const string_type& name, const string_type& ext, const string_type& body, Handler& handler )
{
if ( !body.empty() ) {
//内容を分解する
const param_type param = parse_parameter_helper( body );
// if ( !param.empty() ) {
//
raw_request( method, name, ext, param, handler );
// } else {
// //
// boost::bind( handler, _1, _2 )( "", error::value( error::critical, "bad parameter." ) );
// }
} else {
//
return raw_request( method, name, ext, param_type(), handler );
}
}
示例10: extract
void extract( string_type const & data, string_type & name, string_type & value, basic_cookie<Tag> & c )
{
std::size_t pos = data.find( string_traits_type::convert('=') );
name = data.substr( 0,pos );
if ( pos != string_type::npos )
{
value = data.substr( pos+1 );
}
if ( !value.empty() )
{
if ( *value.begin() == '"' && *value.rbegin() != '"' )
{
value = name + string_traits_type::convert("=") + value;
return;
}
boost::trim_if( value, boost::is_any_of( string_traits_type::convert("\"") ) );
}
set_value( name, value, c );
name.clear();
value.clear();
}
示例11:
inline std::string get_host(std::string default_host = "127.0.0.1") const {
if (!host.empty())
return utf8::cvt<std::string>(host);
return default_host;
}
示例12: open
//Based on the example at https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx.
Process::id_type Process::open(const string_type &command, const string_type &path) {
if(open_stdin)
stdin_fd=std::unique_ptr<fd_type>(new fd_type(NULL));
if(read_stdout)
stdout_fd=std::unique_ptr<fd_type>(new fd_type(NULL));
if(read_stderr)
stderr_fd=std::unique_ptr<fd_type>(new fd_type(NULL));
Handle stdin_rd_p;
Handle stdin_wr_p;
Handle stdout_rd_p;
Handle stdout_wr_p;
Handle stderr_rd_p;
Handle stderr_wr_p;
SECURITY_ATTRIBUTES security_attributes;
security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
security_attributes.bInheritHandle = TRUE;
security_attributes.lpSecurityDescriptor = nullptr;
std::lock_guard<std::mutex> lock(create_process_mutex);
if(stdin_fd) {
if (!CreatePipe(&stdin_rd_p, &stdin_wr_p, &security_attributes, 0) ||
!SetHandleInformation(stdin_wr_p, HANDLE_FLAG_INHERIT, 0))
return 0;
}
if(stdout_fd) {
if (!CreatePipe(&stdout_rd_p, &stdout_wr_p, &security_attributes, 0) ||
!SetHandleInformation(stdout_rd_p, HANDLE_FLAG_INHERIT, 0)) {
return 0;
}
}
if(stderr_fd) {
if (!CreatePipe(&stderr_rd_p, &stderr_wr_p, &security_attributes, 0) ||
!SetHandleInformation(stderr_rd_p, HANDLE_FLAG_INHERIT, 0)) {
return 0;
}
}
PROCESS_INFORMATION process_info;
STARTUPINFO startup_info;
ZeroMemory(&process_info, sizeof(PROCESS_INFORMATION));
ZeroMemory(&startup_info, sizeof(STARTUPINFO));
startup_info.cb = sizeof(STARTUPINFO);
startup_info.hStdInput = stdin_rd_p;
startup_info.hStdOutput = stdout_wr_p;
startup_info.hStdError = stderr_wr_p;
if(stdin_fd || stdout_fd || stderr_fd)
startup_info.dwFlags |= STARTF_USESTDHANDLES;
string_type process_command=command;
#ifdef MSYS_PROCESS_USE_SH
size_t pos=0;
while((pos=process_command.find('\\', pos))!=string_type::npos) {
process_command.replace(pos, 1, "\\\\\\\\");
pos+=4;
}
pos=0;
while((pos=process_command.find('\"', pos))!=string_type::npos) {
process_command.replace(pos, 1, "\\\"");
pos+=2;
}
process_command.insert(0, "sh -c \"");
process_command+="\"";
#endif
BOOL bSuccess = CreateProcess(nullptr, process_command.empty()?nullptr:&process_command[0], nullptr, nullptr, TRUE, 0,
nullptr, path.empty()?nullptr:path.c_str(), &startup_info, &process_info);
if(!bSuccess) {
CloseHandle(process_info.hProcess);
CloseHandle(process_info.hThread);
return 0;
}
else {
CloseHandle(process_info.hThread);
}
if(stdin_fd) *stdin_fd=stdin_wr_p.detach();
if(stdout_fd) *stdout_fd=stdout_rd_p.detach();
if(stderr_fd) *stderr_fd=stderr_rd_p.detach();
closed=false;
data.id=process_info.dwProcessId;
data.handle=process_info.hProcess;
return process_info.dwProcessId;
}
示例13: empty
/// TODO: Check that the uploaded file isn't empty too.
bool empty() const { return value.empty(); }