コード例 #1
0
        string _generateEnumDeclare(ExcelColoumValue value, string content)
        {
            var          tokens  = content.Split(new char[] { '\r', '\n' });
            List <Match> matches = new List <Match>();

            for (int i = 0; i < tokens.Length; ++i)
            {
                var match = ms_enum_prop_reg.Match(tokens[i]);
                if (match.Success)
                {
                    matches.Add(match);
                }
            }
            if (matches.Count > 0)
            {
                if (null == value.enumValues)
                {
                    value.enumValues = new List <int> ();
                }
                value.enumValues.Clear();
                for (int j = 0; j < matches.Count; ++j)
                {
                    int iRes = 0;
                    if (int.TryParse(matches [j].Groups [2].Value, out iRes))
                    {
                        if (!value.enumValues.Contains(iRes))
                        {
                            value.enumValues.Add(iRes);
                        }
                    }
                }
            }
            if (matches.Count > 0)
            {
                StringBuilder kString = new StringBuilder(256);
                var           ret     = kString.ToString();
                kString.AppendFormat("enum {0}\n", _generateEnumVarType(value.name));
                kString.Append("{\n");
                for (int i = 0; i < matches.Count; ++i)
                {
                    kString.AppendFormat("\t{0} = {1};\t//{2}\n", matches[i].Groups[1].Value, matches[i].Groups[2].Value, matches[i].Groups[3].Value);
                }
                kString.Append("}\n");
                ret = kString.ToString();
                return(ret);
            }
            return(string.Empty);
        }
コード例 #2
0
        void _loadProtoHeadLine(ISheet sheet)
        {
            if (null != sheet)
            {
                headLineRow = m_sheet.GetRow(PROTO_HEAD_ROW);
                if (null == headLineRow)
                {
                    _PrintErrMsg(ErrCode.EC_NO_PROTO_HEAD_ROW);
                    return;
                }

                coloumValues         = new ExcelColoumValue[_GetMaxColoumValues(headLineRow)];
                m_iValidColoumCounts = 0;

                //Debug.LogErrorFormat ("sheetName={0} HeadLines = {1}", sheet.SheetName, coloumValues.Length);

                for (int i = 0; i < headLineRow.Cells.Count; ++i)
                {
                    int iColoumIndex = headLineRow.Cells [i].ColumnIndex;

                    if (_IsHeadLineValid(i))
                    {
                        var match = ms_proto_head_reg.Match(headLineRow.Cells[i].StringCellValue);
                        if (!match.Success)
                        {
                            Debug.LogErrorFormat("ROW={0},COL={1},VALUE={2}", PROTO_HEAD_ROW, i + 1, headLineRow.Cells[i].StringCellValue);
                            _PrintErrMsg(ErrCode.EC_PROTO_HEAD_MATCH_FAILED, ms_proto_head_reg);
                            break;
                        }

                        coloumValues[iColoumIndex] = new ExcelColoumValue
                        {
                            iIndex = iColoumIndex,
                            head   = headLineRow.Cells[i].StringCellValue,
                        };

                        m_iValidColoumCounts += 1;
                    }
                }
            }
        }