[SCM] calf/master: + Framework: add a function for indenting a string
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:38:46 UTC 2013
The following commit has been merged in the master branch:
commit b64752e00b4287db9af0084e49d7a09f93c45970
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Wed Dec 31 13:54:21 2008 +0000
+ Framework: add a function for indenting a string
diff --git a/src/calf/utils.h b/src/calf/utils.h
index 7c2fc40..0ec7bea 100644
--- a/src/calf/utils.h
+++ b/src/calf/utils.h
@@ -150,6 +150,9 @@ std::string xml_escape(const std::string &src);
/// Load file from disk into a std::string blob, or throw file_exception
std::string load_file(const std::string &src);
+/// Indent a string by another string (prefix each line)
+std::string indent(const std::string &src, const std::string &indent);
+
};
#endif
diff --git a/src/utils.cpp b/src/utils.cpp
index 6a189c9..0a5dacf 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -103,4 +103,20 @@ std::string f2s(double value)
return ss.str();
}
+std::string indent(const std::string &src, const std::string &indent)
+{
+ std::string dest;
+ size_t pos = 0;
+ do {
+ size_t epos = src.find("\n", pos);
+ if (epos == string::npos)
+ break;
+ dest += indent + src.substr(pos, epos - pos) + "\n";
+ pos = epos + 1;
+ } while(pos < src.length());
+ if (pos < src.length())
+ dest += indent + src.substr(pos);
+ return dest;
+}
+
}
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list