⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chatutils.cpp

📁 ICE3.3.0--聊天程序服务器端demo
💻 CPP
字号:
// **********************************************************************//// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.//// This copy of Chat Demo is licensed to you under the terms// described in the CHAT_DEMO_LICENSE file included in this// distribution.//// **********************************************************************#include <ChatUtils.h>#include <Chat.h>using namespace std;static const unsigned int maxMessageSize = 1024;typedef pair<const string, const string> HtmlEntity;static const HtmlEntity htmlEntities[] = { HtmlEntity("&quot;", "\""),                                           HtmlEntity("&#39;", "'"),                                           HtmlEntity("&lt;", "<"),                                           HtmlEntity("&gt;", ">"),                                           HtmlEntity("&amp;", "&")};stringChatUtils::unstripHtml(const string& s){    string out = s;    for(unsigned int count = 0; count < sizeof(htmlEntities) / sizeof(htmlEntities[0]); ++count)    {        for(string::size_type pos = out.find(htmlEntities[count].first);            pos != string::npos;            pos = out.find(htmlEntities[count].first, pos))        {            out.replace(pos, htmlEntities[count].first.size(), htmlEntities[count].second);        }    }    return out;}voidChatUtils::validateMessage(const string& in){    if(in.size() > maxMessageSize)    {        Chat::InvalidMessageException ex;        ostringstream msg;        msg << "Message length exceeded, maximum length is " << maxMessageSize << " characters.";        ex.reason = msg.str();        throw ex;    }}stringChatUtils::trim(const string& s){    static const string delims = "\t\r\n ";    string::size_type last = s.find_last_not_of(delims);    if(last != string::npos)    {        return s.substr(s.find_first_not_of(delims), last+1);    }    return s;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -