0.1 版
0.2 版
/// <summary>
/// 找出程序设计语言,Java,C#,C++中的自定义类
/// </summary>
/// <param name="sText"></param>
/// <returns></returns>
/// 创建时间: 2022-08-26 最后一次修改时间:2022-08-30
public static StringList_ _Syntax_C_FindCustomClass(this string sText)
{
String sTureText = _Syntax_C_Remove_ExplanatoryNote(sText); //第一,除去注释
StringList_ slResult = new StringList_();
int nPos = sTureText._IndexOfWord("class", 0);
while (nPos != -1)
{
int n = sTureText.IndexOf("{", nPos + 5);
//class node; 前置声明
int iSemicolonPos = sTureText.IndexOf(";",nPos + 5);
if (n != -1 && iSemicolonPos > n) //除了前置声明,第一个分号一定在 { 后面
{
//class Point2d : public Point {
string sClass = sTureText.Substring(nPos + 5, n - nPos - 5);
if(sClass.IndexOf(":") != -1)
{
StringList_ slTemp = sClass._Split(":");
if(slTemp.Count > 1)
{
slResult.Add(slTemp[0].Trim());
slTemp = slTemp[1].Trim()._Split(" ", true);
if(slTemp.Count > 1)
{
slResult.Add(slTemp[1]); //父类
}
}
}
else //template < class type, int dim > class Point { } = type, int dim > class Point
{
if(sClass.IndexOf(',') != -1 || sClass.IndexOf('>') != -1) //模板 template < class T >
{
}
else
{
slResult.Add(sClass.Trim());
}
}
}
nPos = sTureText._IndexOfWord("class", nPos + 5);
}
return slResult;
}
/// <summary>
/// 找出程序设计语言,Java,C#,C++中的自定义类
/// </summary>
/// <param name="sText"></param>
/// <returns></returns>
/// 创建时间: 2022-08-26 最后一次修改时间:2022-08-30
public static StringList_ _Syntax_C_FindCustomClass(this string sText)
{
String sTureText = _Syntax_C_Remove_ExplanatoryNote(sText); //第一,除去注释
StringList_ slResult = new StringList_();
int nPos = sTureText._IndexOfWord("class", 0);
while (nPos != -1)
{
int n = sTureText.IndexOf("{", nPos + 5);
//class node; 前置声明
int iSemicolonPos = sTureText.IndexOf(";",nPos + 5);
if (n != -1 && iSemicolonPos > n) //除了前置声明,第一个分号一定在 { 后面
{
//class Point2d : public Point {
string sClass = sTureText.Substring(nPos + 5, n - nPos - 5);
if(sClass.IndexOf(":") != -1)
{
StringList_ slTemp = sClass._Split(":");
if(slTemp.Count > 1)
{
slResult.Add(slTemp[0].Trim());
slTemp = slTemp[1].Trim()._Split(" ", true);
if(slTemp.Count > 1)
{
slResult.Add(slTemp[1]); //父类
}
}
}
else //template < class type, int dim > class Point { } = type, int dim > class Point
{
if(sClass.IndexOf(',') != -1 || sClass.IndexOf('>') != -1) //模板 template < class T >
{
}
else
{
slResult.Add(sClass.Trim());
}
}
}
nPos = sTureText._IndexOfWord("class", nPos + 5);
}
return slResult;
}