[openrtm-commit:03307] r3273 - trunk/OpenRTM-aist/src/lib/coil/common
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 3月 28日 (水) 13:24:59 JST
Author: miyamoto
Date: 2018-03-28 13:24:59 +0900 (Wed, 28 Mar 2018)
New Revision: 3273
Modified:
trunk/OpenRTM-aist/src/lib/coil/common/stringutil.cpp
trunk/OpenRTM-aist/src/lib/coil/common/stringutil.h
Log:
[merge] r3184-3194 have been merged from RELENG_1_2.
Modified: trunk/OpenRTM-aist/src/lib/coil/common/stringutil.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/common/stringutil.cpp 2018-03-28 04:24:46 UTC (rev 3272)
+++ trunk/OpenRTM-aist/src/lib/coil/common/stringutil.cpp 2018-03-28 04:24:59 UTC (rev 3273)
@@ -27,6 +27,7 @@
#include <string.h>
#include <cctype>
#include <cstdio>
+#include <coil/OS.h>
#ifdef __QNX__
using std::toupper;
@@ -754,4 +755,61 @@
return std::string(str);
}
+
+ /*!
+ * @if jp
+ * @brief ʸ»úÎóÃæ¤Î´Ä¶ÊÑ¿ô¤òÃÖ¤´¹¤¨¤ë
+ *
+ *
+ *
+ * ʸ»úÎóÃæ¤Ë${}¤Ç°Ï¤Þ¤ì¤¿Ê¸»úÎ󤬤¢¤ë¾ì¹ç¤Ë¡¢´Ä¶ÊÑ¿ô¤ÈÃÖ¤´¹¤¨¤ë
+ * Î㡧${RTM_ROOT}\bin -> C:\Program Files (x86)\OpenRTM-aist\1.1.2\
+ *
+ * @param str ÃÖ¤´¹¤¨Á°¤Îʸ»úÎó
+ * @return ÃÖ¤´¹¤¨¸å¤Îʸ»úÎó
+ *
+ * @else
+ * @brief
+ *
+ * @param str
+ * @return
+ *
+ * @return
+ *
+ * @endif
+ */
+ std::string replaceEnv(std::string str)
+ {
+ vstring tmp = split(str, "${");
+ if (tmp.size() < 2)
+ {
+ return str;
+ }
+ vstring ret;
+ for (vstring::iterator itr = tmp.begin(); itr != tmp.end(); ++itr)
+ {
+ vstring tmp2 = split((*itr), "}");
+ if (tmp2.size() == 2)
+ {
+ char s[100];
+ strcpy(s, coil::getenv(tmp2[0].c_str()));
+ ret.push_back(std::string(s));
+ ret.push_back(tmp2[1]);
+ }
+ else
+ {
+ ret.push_back((*itr));
+ }
+
+ }
+
+
+ std::string ret_str = "";
+ for (vstring::iterator itr = ret.begin(); itr != ret.end(); ++itr)
+ {
+ ret_str = ret_str + (*itr);
+ }
+ return ret_str;
+ }
+
}; // namespace coil
Modified: trunk/OpenRTM-aist/src/lib/coil/common/stringutil.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/common/stringutil.h 2018-03-28 04:24:46 UTC (rev 3272)
+++ trunk/OpenRTM-aist/src/lib/coil/common/stringutil.h 2018-03-28 04:24:59 UTC (rev 3273)
@@ -867,6 +867,30 @@
* @endif
*/
std::string sprintf(char const * __restrict fmt, ...);
+
+ /*!
+ * @if jp
+ * @brief 文字列中の環境変数を置き換える
+ *
+ *
+ *
+ * 文字列中に${}で囲まれた文字列がある場合に、環境変数と置き換える
+ * 例:${RTM_ROOT}\bin -> C:\Program Files (x86)\OpenRTM-aist\1.1.2\
+ *
+ * @param str 置き換え前の文字列
+ * @return 置き換え後の文字列
+ *
+ * @else
+ * @brief
+ *
+ * @param str
+ * @return
+ *
+ * @return
+ *
+ * @endif
+ */
+ std::string replaceEnv(std::string str);
}; // namepsace coil
#endif // COIL_STRINGUTIL_H
openrtm-commit メーリングリストの案内