[Flared-svn-003] SF.net SVN: flared: [4] src/flare_util.cc
Status: Beta
Brought to you by:
masaki-fujimoto
|
From: <mas...@us...> - 2007-12-11 03:24:16
|
Revision: 4
http://flared.svn.sourceforge.net/flared/?rev=4&view=rev
Author: masaki-fujimoto
Date: 2007-12-10 19:24:21 -0800 (Mon, 10 Dec 2007)
Log Message:
-----------
- added missing file
Added Paths:
-----------
src/flare_util.cc
Added: src/flare_util.cc
===================================================================
--- src/flare_util.cc (rev 0)
+++ src/flare_util.cc 2007-12-11 03:24:21 UTC (rev 4)
@@ -0,0 +1,58 @@
+/**
+ * flare_util.cc
+ *
+ * @author Masaki Fujimoto <fuj...@ph...>
+ */
+#include "flare.h"
+
+namespace gree {
+namespace flare {
+
+// {{{ constructor/destructor
+// }}}
+
+// {{{ public methods
+/**
+ * join vector<string>
+ *
+ * @todo use template
+ * @todo define type and use operator overload
+ * @access public
+ */
+string util::join(vector<string> list, string glue) {
+ vector<string>::iterator it;
+ string s;
+ for (it = list.begin(); it != list.end(); it++) {
+ if (s.size() > 0) {
+ s += glue;
+ }
+ s += *it;
+ }
+
+ return s;
+}
+
+/**
+ * split string
+ *
+ * @todo use template
+ * @todo define type and use operator overload
+ * @access public
+ */
+vector<string> util::split(string s, string sep) {
+ vector<string> r;
+
+ typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
+ boost::char_separator<char> separator(sep.c_str());
+ tokenizer token_list(s, separator);
+ for (tokenizer::iterator it = token_list.begin(); it != token_list.end(); it++) {
+ r.push_back(*it);
+ }
+
+ return r;
+}
+// }}}
+
+} // namespace flare
+} // namespace gree
+// vim: foldmethod=marker tabstop=4 shiftwidth=4 autoindent
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|