コード例 #1
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();
            int __idx    = 0;
            var comment  = grid[__idx++];
            var attrName = grid[__idx++];
            var attrType = grid[__idx++];

            info.FileName    = fileName;
            info.KeyTypeName = CSV2CppConst.CSVType2CodeType(attrType[0]);
            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;
        }
コード例 #2
0
 public void Init()
 {
     AttriType2FuncName = CSV2CppConst.CSVType2FuncName(AttriTypeName);
     AttriTypeName      = CSV2CppConst.CSVType2CodeType(AttriTypeName);
 }