char string library. There is a character string splitting function.
Revision 1:fc299d8c1c7e, committed 2017-12-03
- Comitter:
- tichise
- Date:
- Sun Dec 03 06:19:23 2017 +0000
- Parent:
- 0:c6bf0554e2f3
- Child:
- 2:dbd6f2a04946
- Commit message:
- change name
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CharUtil.cpp Sun Dec 03 06:19:23 2017 +0000 @@ -0,0 +1,21 @@ +#include "CharUtil.h" +#include "mbed.h" + +#define MAXITEM 20 // 数字が大きすぎるとメモリーオーバーエラーがでる + +CharUtil::CharUtil() { +} + +int CharUtil::split(char *base, const char *delim, char *outlist[]){ + char *token; + int cnt = 0; + + token = strtok(base, delim); + + while(token != NULL && cnt < MAXITEM) { + outlist[cnt++] = token; + token = strtok(NULL, delim); + } + + return cnt; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CharUtil.h Sun Dec 03 06:19:23 2017 +0000 @@ -0,0 +1,20 @@ +#ifndef MBED_CHAR_UTIL_H +#define MBED_CHAR_UTIL_H + +#include "mbed.h" +#include <math.h> +#include <string> +#include <string.h> +#include <list> + +class CharUtil +{ +public: + CharUtil(); + int split(char *str, const char *delim, char *outlist[]); + + +private: +}; + +#endif \ No newline at end of file
--- a/StringUtil.cpp Sun Dec 03 05:35:31 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -#include "StringUtil.h" -#include "mbed.h" - -#define MAXITEM 20 // 数字が大きすぎるとメモリーオーバーエラーがでる - -StringUtil::StringUtil() { -} - -int StringUtil::splitChar( char *str, const char *delim, char *outlist[] ){ - char *tk; - int cnt = 0; - - tk = strtok( str, delim ); - - while( tk != NULL && cnt < MAXITEM ) { - outlist[cnt++] = tk; - tk = strtok( NULL, delim ); - } - - return cnt; -} \ No newline at end of file
--- a/StringUtil.h Sun Dec 03 05:35:31 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -#ifndef MBED_STRING_UTIL_H -#define MBED_STRING_UTIL_H - -#include "mbed.h" -#include <math.h> -#include <string> -#include <string.h> -#include <list> - -class StringUtil -{ -public: - StringUtil(); - int splitChar( char *str, const char *delim, char *outlist[]); - - -private: -}; - -#endif \ No newline at end of file