Esempio n. 1
0
 private int skipNum;             //跳过的字数
 string ReplaceClsInfo(string info, GenTypeInfo typeInfo)
 {
     info = info.Replace("#FileName", typeInfo.FileName);
     info = info.Replace("#KeyTypeName", typeInfo.KeyTypeName);
     info = info.Replace("#KeyName", typeInfo.KeyName);
     info = info.Replace("#StructName", typeInfo.StructName);
     info = info.Replace("#ClsName", typeInfo.ClsName);
     return(info);
 }
Esempio n. 2
0
        string ReplaceAttrInfo(string info, GenTypeInfo typeInfo, ColInfo colInfo)
        {
            info = ReplaceClsInfo(info, typeInfo);

            info = info.Replace("#AttriName", colInfo.AttriName);
            info = info.Replace("#AttriType2FuncName", colInfo.AttriType2FuncName);
            info = info.Replace("#AttriTypeName", colInfo.AttriTypeName);
            info = info.Replace("#AttriCommment", colInfo.AttriCommment);
            return(info);
        }
Esempio n. 3
0
        void ReadCsv(string path)
        {
            var csvText  = File.ReadAllText(path, Encoding.UTF8);
            var fileName = Path.GetFileName(path);

            fileName = fileName.Split('.')[0];
            Debug.Log(fileName);
            totalFileNum++;
            if (string.IsNullOrEmpty(csvText))
            {
                return;
            }
            string[][] grid = CsvParser.Parse(csvText);
            if (grid.Length < 3)
            {
                Debug.LogError("CSV2Cpp CodeGen Csv table grid.Length < 3");
                return;
            }
            int len = grid[0].Length;

            foreach (var row in grid)
            {
                if (row.Length != len)
                {
                    Debug.LogError(string.Format("{2} csv parse error not each row's len is the same row.Length{0} != titleLen{1}", row.Length, len, path));
                }
            }
            var info     = new GenTypeInfo();
            var comment  = grid[GlobalVal.CommentIdx];
            var attrName = grid[GlobalVal.AttrNameIdx];
            var attrType = grid[GlobalVal.TypeIdx];

            info.RawFileName = fileName;
            int keyIdx = GetMainKeyIdx(attrName);

            info.KeyTypeName   = attrType[keyIdx];
            info.KeyTypeColIdx = keyIdx.ToString();
            info.KeyName       = attrName[0];
            for (int i = 0; i < len; i++)
            {
                var col = new ColInfo();
                col.AttriCommment = comment[i];
                col.AttriName     = attrName[i];
                col.AttriTypeName = attrType[i];
                col.Init();
                info.colInfo.Add(col);
            }
            info.Init();
            infos.Add(info);
            //Print(grid);
            return;
        }
Esempio n. 4
0
        string ReplaceAttrInfo(string info, GenTypeInfo typeInfo, ColInfo colInfo)
        {
            info = info.Replace("#FileName", typeInfo.FileName);
            info = info.Replace("#KeyTypeName", typeInfo.KeyTypeName);
            info = info.Replace("#KeyName", typeInfo.KeyName);
            info = info.Replace("#StructName", typeInfo.StructName);
            info = info.Replace("#ClsName", typeInfo.ClsName);

            info = info.Replace("#AttriName", colInfo.AttriName);
            info = info.Replace("#AttriType2FuncName", colInfo.AttriType2FuncName);
            info = info.Replace("#AttriTypeName", colInfo.AttriTypeName);
            info = info.Replace("#AttriCommment", colInfo.AttriCommment);
            return(info);
        }
Esempio n. 5
0
        //替换所有属性标志
        string ParseAllAttrTag(string content, GenTypeInfo typeInfo)
        {
            var ret = Replace(content, attrTagBegin, attrTagEnd, (str) => {
                //正对一个属性标志 需要遍历所有的属性
                StringBuilder sb = new StringBuilder();
                foreach (var colInfo in typeInfo.colInfo)
                {
                    curColInfo      = colInfo;
                    var _replaceStr = ReplaceAttrInfo(str, curTypeInfo, curColInfo);
                    sb.Append(_replaceStr);
                }
                return(sb.ToString());
            });

            return(ret);
        }
Esempio n. 6
0
        //替换所有类标志
        string ParseAllClsTag(string content)
        {
            var ret = Replace(content, clsTagBegin, clsTagEnd, (str) => {
                //正对一个类标志 需要遍历所有的类
                StringBuilder sb = new StringBuilder();
                foreach (var info in infos)
                {
                    curTypeInfo     = info;
                    var _replaceStr = ParseAllAttrTag(str, curTypeInfo);
                    _replaceStr     = ReplaceClsInfo(_replaceStr, curTypeInfo);
                    sb.Append(_replaceStr);
                }
                return(sb.ToString());
            });

            return(ret);
        }