[openrtm-commit:03110] r3186 - in branches/RELENG_1_2/OpenRTM-aist/src/lib: coil/common rtm
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 1月 23日 (火) 13:29:28 JST
Author: miyamoto
Date: 2018-01-23 13:29:28 +0900 (Tue, 23 Jan 2018)
New Revision: 3186
Modified:
branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/common/stringutil.cpp
branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/common/stringutil.h
branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.cpp
Log:
[incompat,->RELENG_1_2] refs #4430
Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/common/stringutil.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/common/stringutil.cpp 2018-01-23 00:38:28 UTC (rev 3185)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/common/stringutil.cpp 2018-01-23 04:29:28 UTC (rev 3186)
@@ -754,4 +754,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: branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/common/stringutil.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/common/stringutil.h 2018-01-23 00:38:28 UTC (rev 3185)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/coil/common/stringutil.h 2018-01-23 04:29:28 UTC (rev 3186)
@@ -858,6 +858,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
Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.cpp 2018-01-23 00:38:28 UTC (rev 3185)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/ManagerConfig.cpp 2018-01-23 04:29:28 UTC (rev 3186)
@@ -33,6 +33,14 @@
{
// The list of default configuration file path.
+#ifdef RTM_OS_WIN32
+ const char* ManagerConfig::config_file_path[] =
+ {
+ "./rtc.conf",
+ "${RTM_ROOT}bin/${RTM_VC_VERSION}/rtc.conf",
+ NULL
+ };
+#else
const char* ManagerConfig::config_file_path[] =
{
"./rtc.conf",
@@ -42,6 +50,7 @@
"/usr/local/etc/rtc/rtc.conf",
NULL
};
+#endif
// Environment value to specify configuration file
const char* ManagerConfig::config_file_env = "RTC_MANAGER_CONFIG";
@@ -213,12 +222,14 @@
int i = 0;
while (config_file_path[i] != NULL)
{
- if (fileExist(config_file_path[i]))
- {
- m_configFile = config_file_path[i];
- return true;
- }
- ++i;
+ std::string cpath = coil::replaceEnv(config_file_path[i]);
+
+ if (fileExist(cpath))
+ {
+ m_configFile = cpath;
+ return true;
+ }
+ ++i;
}
return false;
}
More information about the openrtm-commit
mailing list