1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>log4cpp: StringUtil.hh Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.2 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>File Members</span></a></li>
</ul>
</div>
<h1>StringUtil.hh</h1><a href="StringUtil_8hh.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * StringUtil.hh</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright 2002, Log4cpp Project. All rights reserved.</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * See the COPYING file for the terms of usage and distribution.</span>
<a name="l00007"></a>00007 <span class="comment"> */</span>
<a name="l00008"></a>00008
<a name="l00009"></a>00009 <span class="preprocessor">#ifndef _LOG4CPP_STRINGUTIL_HH</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span><span class="preprocessor">#define _LOG4CPP_STRINGUTIL_HH</span>
<a name="l00011"></a>00011 <span class="preprocessor"></span>
<a name="l00012"></a>00012 <span class="preprocessor">#include "<a class="code" href="PortabilityImpl_8hh.html">PortabilityImpl.hh</a>"</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include <string></span>
<a name="l00014"></a>00014 <span class="preprocessor">#include <vector></span>
<a name="l00015"></a>00015 <span class="preprocessor">#include <climits></span>
<a name="l00016"></a>00016 <span class="preprocessor">#include <stdarg.h></span>
<a name="l00017"></a>00017
<a name="l00018"></a>00018 <span class="keyword">namespace </span>log4cpp {
<a name="l00019"></a>00019
<a name="l00020"></a><a class="code" href="classlog4cpp_1_1StringUtil.html">00020</a> <span class="keyword">class </span><a class="code" href="classlog4cpp_1_1StringUtil.html">StringUtil</a> {
<a name="l00021"></a>00021 <span class="keyword">public</span>:
<a name="l00022"></a>00022
<a name="l00029"></a>00029 <span class="keyword">static</span> std::string <a class="code" href="classlog4cpp_1_1StringUtil.html#2e0e62788cef69953a613e72d0d62516" title="Returns a string contructed from the a format specifier and a va_list of arguments...">vform</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* format, va_list args);
<a name="l00030"></a>00030
<a name="l00035"></a>00035 <span class="keyword">static</span> std::string <a class="code" href="classlog4cpp_1_1StringUtil.html#135b34af8fadf914b7067fa2af7937ea" title="Returns a string identical to the given string but without leading or trailing HTABs...">trim</a>(<span class="keyword">const</span> std::string& s);
<a name="l00036"></a>00036
<a name="l00050"></a>00050 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classlog4cpp_1_1StringUtil.html#24966cf8cacc3fb702b8466cfd5314b5" title="splits a string into a vector of string segments based on the given delimiter.">split</a>(std::vector<std::string>& v,
<a name="l00051"></a>00051 <span class="keyword">const</span> std::string& s, <span class="keywordtype">char</span> delimiter,
<a name="l00052"></a>00052 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> maxSegments = INT_MAX);
<a name="l00063"></a><a class="code" href="classlog4cpp_1_1StringUtil.html#b0cb488065a2630ea8d29f12ca5e1c77">00063</a> <span class="keyword">template</span><<span class="keyword">typename</span> T> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classlog4cpp_1_1StringUtil.html#24966cf8cacc3fb702b8466cfd5314b5" title="splits a string into a vector of string segments based on the given delimiter.">split</a>(T& output,
<a name="l00064"></a>00064 <span class="keyword">const</span> std::string& s, <span class="keywordtype">char</span> delimiter,
<a name="l00065"></a>00065 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> maxSegments = INT_MAX) {
<a name="l00066"></a>00066 std::string::size_type <a class="code" href="namespacelog4cpp.html#cbf828259e8eeb5d15aa2b5746ef8c23" title="left manipulator">left</a> = 0;
<a name="l00067"></a>00067 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
<a name="l00068"></a>00068 <span class="keywordflow">for</span>(i = 1; i < maxSegments; i++) {
<a name="l00069"></a>00069 std::string::size_type right = s.find(delimiter, left);
<a name="l00070"></a>00070 <span class="keywordflow">if</span> (right == std::string::npos) {
<a name="l00071"></a>00071 <span class="keywordflow">break</span>;
<a name="l00072"></a>00072 }
<a name="l00073"></a>00073 *output++ = s.substr(left, right - left);
<a name="l00074"></a>00074 left = right + 1;
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076
<a name="l00077"></a>00077 *output++ = s.substr(left);
<a name="l00078"></a>00078 <span class="keywordflow">return</span> i;
<a name="l00079"></a>00079 }
<a name="l00080"></a>00080 };
<a name="l00081"></a>00081 }
<a name="l00082"></a>00082
<a name="l00083"></a>00083 <span class="preprocessor">#endif // _LOG4CPP_STRINGUTIL_HH</span>
<a name="l00084"></a>00084 <span class="preprocessor"></span>
</pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Mon Sep 3 11:54:29 2007 for log4cpp by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.2 </small></address>
</body>
</html>
|