本文整理汇总了C++中XString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ XString::size方法的具体用法?C++ XString::size怎么用?C++ XString::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XString
的用法示例。
在下文中一共展示了XString::size方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: intif_GMmessage
// Message for all GMs on all map servers
void intif_GMmessage(XString mes)
{
WFIFOW(char_fd, 0) = 0x3000;
size_t len = mes.size() + 1;
WFIFOW(char_fd, 2) = 4 + len;
WFIFO_STRING(char_fd, 4, mes, len);
WFIFOSET(char_fd, WFIFOW(char_fd, 2));
}
示例2: tmw_CheckChatLameness
// Returns true if more than 50% of input message is caps or punctuation
bool tmw_CheckChatLameness(dumb_ptr<map_session_data>, XString message)
{
int lame = 0;
for (char c : message)
{
if (c <= ' ')
continue;
if (c > '~')
continue;
if ('0' <= c && c <= '9')
continue;
if ('a' <= c && c <= 'z')
continue;
lame++;
}
return message.size() > 7 && lame > message.size() / 2;
}
示例3: intif_party_message
// パーティ会話送信
void intif_party_message(int party_id, int account_id, XString mes)
{
size_t len = mes.size() + 1;
WFIFOW(char_fd, 0) = 0x3027;
WFIFOW(char_fd, 2) = len + 12;
WFIFOL(char_fd, 4) = party_id;
WFIFOL(char_fd, 8) = account_id;
WFIFO_STRING(char_fd, 12, mes, len);
WFIFOSET(char_fd, len + 12);
}
示例4: mapif_GMmessage
// GMメッセージ送信
static
void mapif_GMmessage(XString mes)
{
size_t str_len = mes.size() + 1;
size_t msg_len = str_len + 4;
uint8_t buf[msg_len];
WBUFW(buf, 0) = 0x3800;
WBUFW(buf, 2) = msg_len;
WBUF_STRING(buf, 4, mes, str_len);
mapif_sendall(buf, msg_len);
}
示例5: XSimpleTimeZone
XIRef<XTimeZone> XSimpleTimeZone::FromXML(XIRef<XDomParserNode> node)
{
const XString utcOffsetStr = node->GetMetaData("utcOffset");
const XString dstOffsetStr = node->GetMetaData("dstOffset");
if(node->GetTagName() != "XSimpleTimeZone" ||
utcOffsetStr.empty() ||
(!verifyDigit(utcOffsetStr[0]) && utcOffsetStr[0] != '-') ||
count_if(utcOffsetStr.begin() + 1, utcOffsetStr.end(), verifyDigit) != (int)utcOffsetStr.size() - 1 ||
dstOffsetStr.empty() ||
(!verifyDigit(dstOffsetStr[0]) && dstOffsetStr[0] != '-') ||
count_if(dstOffsetStr.begin() + 1, dstOffsetStr.end(), verifyDigit) != (int)dstOffsetStr.size() - 1)
{
return 0;
}
const int utcOffset = utcOffsetStr.ToInt();
const int dstOffset = dstOffsetStr.ToInt();
return new XSimpleTimeZone(utcOffset, dstOffset);
}
示例6: while
MD5_state MD5_from_string(XString msg)
{
MD5_state state;
MD5_init(&state);
MD5_block block;
const uint64_t msg_full_len = msg.size();
while (msg.size() >= 64)
{
for (int i = 0; i < 0x10; i++)
X[i] = msg[4 * i + 0] | msg[4 * i + 1] << 8 | msg[4 * i + 2] << 16 | msg[4 * i + 3] << 24;
MD5_do_block(&state, block);
msg = msg.xslice_t(64);
}
// now pad 1-512 bits + the 64-bit length - may be two blocks
uint8_t buf[0x40] = {};
really_memcpy(buf, reinterpret_cast<const uint8_t *>(msg.data()), msg.size());
buf[msg.size()] = 0x80; // a single one bit
if (64 - msg.size() > 8)
{
for (int i = 0; i < 8; i++)
buf[0x38 + i] = (msg_full_len * 8) >> (i * 8);
}
for (int i = 0; i < 0x10; i++)
X[i] = buf[4 * i + 0] | buf[4 * i + 1] << 8 | buf[4 * i + 2] << 16 | buf[4 * i + 3] << 24;
MD5_do_block(&state, block);
if (64 - msg.size() <= 8)
{
really_memset0(buf, 0x38);
for (int i = 0; i < 8; i++)
buf[0x38 + i] = (msg_full_len * 8) >> (i * 8);
for (int i = 0; i < 0x10; i++)
X[i] = buf[4 * i + 0] | buf[4 * i + 1] << 8 | buf[4 * i + 2] << 16 | buf[4 * i + 3] << 24;
MD5_do_block(&state, block);
}
示例7: create_vpacket
Buffer create_vpacket(Packet_Head<id>& head, const XString& repeat)
{
static_assert(id == Packet_Head<id>::PACKET_ID, "Packet_Head<id>::PACKET_ID");
static_assert(headsize == sizeof(NetPacket_Head<id>), "NetPacket_Head<id>");
static_assert(id == Packet_Repeat<id>::PACKET_ID, "Packet_Repeat<id>::PACKET_ID");
static_assert(repeatsize == sizeof(NetPacket_Repeat<id>), "NetPacket_Repeat<id>");
static_assert(repeatsize == 1, "repeatsize");
// since it's already allocated, it can't overflow address space
size_t total_length = sizeof(NetPacket_Head<id>) + (repeat.size() + 1) * sizeof(NetPacket_Repeat<id>);
head.magic_packet_length = total_length;
if (head.magic_packet_length != total_length)
{
return Buffer();
}
Buffer buf;
buf.bytes.resize(total_length);
auto& net_head = reinterpret_cast<NetPacket_Head<id>&>(
*(buf.bytes.begin() + 0));
std::vector<NetPacket_Repeat<id>> net_repeat(repeat.size() + 1);
if (!native_to_network(&net_head, head))
{
return Buffer();
}
for (size_t i = 0; i < repeat.size(); ++i)
{
auto& net_repeat_i = reinterpret_cast<NetPacket_Repeat<id>&>(
*(buf.bytes.begin()
+ sizeof(NetPacket_Head<id>)
+ i));
net_repeat_i.c = Byte{static_cast<uint8_t>(repeat[i])};
}
auto& net_repeat_repeat_size = reinterpret_cast<NetPacket_Repeat<id>&>(
*(buf.bytes.begin()
+ sizeof(NetPacket_Head<id>)
+ repeat.size()));
net_repeat_repeat_size.c = Byte{static_cast<uint8_t>('\0')};
return buf;
}
示例8: mapif_party_message
// パーティ内発言
static
void mapif_party_message(int party_id, int account_id, XString mes)
{
size_t len = mes.size() + 1;
unsigned char buf[len + 12];
WBUFW(buf, 0) = 0x3827;
WBUFW(buf, 2) = len + 12;
WBUFL(buf, 4) = party_id;
WBUFL(buf, 8) = account_id;
WBUF_STRING(buf, 12, mes, len);
mapif_sendall(buf, len + 12);
}
示例9: e_mail_check
//---------------------------------------------------
// E-mail check: return 0 (not correct) or 1 (valid).
//---------------------------------------------------
bool e_mail_check(XString email)
{
// athena limits
if (email.size() < 3 || email.size() > 39)
return 0;
// part of RFC limits (official reference of e-mail description)
XString::iterator at = std::find(email.begin(), email.end(), '@');
if (at == email.end())
return 0;
XString username = email.xislice_h(at);
XString hostname = email.xislice_t(at + 1);
if (!username || !hostname)
return 0;
if (hostname.contains('@'))
return 0;
if (hostname.front() == '.' || hostname.back() == '.')
return 0;
if (hostname.contains_seq(".."))
return 0;
if (email.contains_any(" ;"))
return 0;
return email.is_print();
}
示例10: put_line
void WriteFile::put_line(XString xs)
{
really_put(xs.data(), xs.size());
if (!xs.endswith('\n'))
put('\n');
}