📄 std__ex_8cpp-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>std_ex.cpp Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> </center><hr><h1>std_ex.cpp</h1><div class="fragment"><pre>00001 <span class="comment">// std_ex.cpp</span>00002 <span class="comment">//</span>00003 <span class="comment">// Extensions to the std library</span>00004 <span class="comment">//</span>00005 <span class="comment">//</span>00006 <span class="comment">// Copyright (c) 2002 Rob Wiskow</span>00007 <span class="comment">// rob-dev@boxedchaos.com</span>00008 <span class="comment">//</span>00009 <span class="comment">// This library is free software; you can redistribute it and/or</span>00010 <span class="comment">// modify it under the terms of the GNU Lesser General Public</span>00011 <span class="comment">// License as published by the Free Software Foundation; either</span>00012 <span class="comment">// version 2.1 of the License, or (at your option) any later version.</span>00013 <span class="comment">//</span>00014 <span class="comment">// This library is distributed in the hope that it will be useful,</span>00015 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>00016 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>00017 <span class="comment">// Lesser General Public License for more details.</span>00018 <span class="comment">//</span>00019 <span class="comment">// You should have received a copy of the GNU Lesser General Public</span>00020 <span class="comment">// License along with this library; if not, write to the Free Software</span>00021 <span class="comment">// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>00022 <span class="comment">//</span>00023 00024 <span class="preprocessor">#include "wgui_include_config.h"</span>00025 <span class="preprocessor">#include "std_ex.h"</span>00026 <span class="preprocessor">#include <sstream></span>00027 00028 00029 <span class="keyword">namespace </span>stdex00030 {00031 00032 00033 std::string itoa(<span class="keyword">const</span> <span class="keywordtype">int</span> iValue)00034 {00035 std::ostringstream sOutStream;00036 sOutStream << iValue;00037 <span class="keywordflow">return</span> sOutStream.str();00038 }00039 00040 00041 std::string ltoa(<span class="keyword">const</span> <span class="keywordtype">long</span> lValue)00042 {00043 std::ostringstream sOutStream;00044 sOutStream << lValue;00045 <span class="keywordflow">return</span> sOutStream.str();00046 }00047 00048 00049 std::string ftoa(<span class="keyword">const</span> <span class="keywordtype">float</span> fValue)00050 {00051 std::ostringstream sOutStream;00052 sOutStream << fValue;00053 <span class="keywordflow">return</span> sOutStream.str();00054 }00055 00056 00057 std::string dtoa(<span class="keyword">const</span> <span class="keywordtype">double</span> dValue)00058 {00059 std::ostringstream sOutStream;00060 sOutStream << dValue;00061 <span class="keywordflow">return</span> sOutStream.str();00062 }00063 00064 00065 <span class="keywordtype">int</span> atoi(<span class="keyword">const</span> std::string& sValue)00066 {00067 <span class="keywordtype">int</span> iResult = 0;00068 std::stringstream sTranslation;00069 sTranslation << sValue;00070 sTranslation >> iResult;00071 <span class="keywordflow">return</span> iResult;00072 }00073 00074 00075 <span class="keywordtype">long</span> atol(<span class="keyword">const</span> std::string& sValue)00076 {00077 <span class="keywordtype">long</span> lResult = 0;00078 std::stringstream sTranslation;00079 sTranslation << sValue;00080 sTranslation >> lResult;00081 <span class="keywordflow">return</span> lResult;00082 }00083 00084 00085 <span class="keywordtype">float</span> atof(<span class="keyword">const</span> std::string& sValue)00086 {00087 <span class="keywordtype">float</span> fResult = 0.0;00088 std::stringstream sTranslation;00089 sTranslation << sValue;00090 sTranslation >> fResult;00091 <span class="keywordflow">return</span> fResult;00092 }00093 00094 00095 <span class="keywordtype">double</span> atod(<span class="keyword">const</span> std::string& sValue)00096 {00097 <span class="keywordtype">double</span> dResult = 0.0;00098 std::stringstream sTranslation;00099 sTranslation << sValue;00100 sTranslation >> dResult;00101 <span class="keywordflow">return</span> dResult;00102 }00103 00104 00105 std::string TrimString(<span class="keyword">const</span> std::string& sString)00106 {00107 std::string::size_type start = sString.find_first_not_of(<span class="stringliteral">" \t"</span>);00108 std::string::size_type end = sString.find_last_not_of(<span class="stringliteral">" \t"</span>);00109 std::string sResult = <span class="stringliteral">""</span>;00110 <span class="keywordflow">if</span> (start != std::string::npos)00111 {00112 sResult = sString.substr(start, end - start + 1);00113 }00114 00115 <span class="keywordflow">return</span> sResult;00116 }00117 00118 00119 std::list<std::string> DetokenizeString(<span class="keyword">const</span> std::string& sString, <span class="keyword">const</span> std::string& sDelimiters)00120 {00121 std::string sStringCopy(sString);00122 std::list<std::string> Tokens;00123 00124 <span class="keywordflow">while</span> (! sStringCopy.empty())00125 {00126 std::string::size_type DelimiterIndex = sStringCopy.find_first_of(sDelimiters);00127 <span class="keywordflow">if</span> (DelimiterIndex == std::string::npos)00128 {00129 Tokens.push_back(sStringCopy);00130 sStringCopy = <span class="stringliteral">""</span>;00131 }00132 <span class="keywordflow">else</span>00133 {00134 Tokens.push_back(sStringCopy.substr(0, DelimiterIndex));00135 }00136 sStringCopy = sStringCopy.substr(DelimiterIndex + 1);00137 }00138 00139 <span class="keywordflow">return</span> Tokens;00140 }00141 00142 }</pre></div><hr><address style="align: right;"><small>Generated on Sat Oct 25 12:43:21 2003 for wGui by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.18 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -