You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include "WDouble.h"
using wuya::WDouble;
class AFX_EXT_CLASS CStringUtility
{
public:
CStringUtility(void);
~CStringUtility(void);
/**
* @brief 分析字符串
* 1> 逗号和TAB分割的文本行若两个逗号或文本连续存在则判定为中间有一个空字符串
* 2> 空格分割的文本行,空格的个数没有限制
* @param [in] strLine 一行文本
* [out] strarrrayResult 返回分析后的文本
* [out] strDivided 分割字符串
* @return 返回劈分出的字符串个数
*/
static int AnalyzeLine(const CString& strLine,CStringArray& strarrayResult,const CString& strDivided = GetDividedDef());
/**
* @brief 在字符串数组中查找字符串
* @param [in] strarray 字符串数组
* [in] str 字符串
* @return 若查找的字符串存在,返回字符串索引;若不存在,返回-1
*/
static int FindStringInArray(const CStringArray& strarray,const CString& str);
static CString GetString(WDouble wdValue);
static CString GetString(int iValue);
static void SetDividedDef(const CString& strDivided);
static CString GetDividedDef();
private:
static int AnalyzeOneLine(char* buf,int* a,const CString& strDivided);
static int AnalyzeOneLineC(char* buf,int* a); ///< 利用逗号分割
static int AnalyzeOneLineT(char* buf,int* a); ///< 利用TAB键分割
private:
static CString m_strDivided; ///< 分割的符号、默认为_T(" \t,")
};