short 클래스_데이터_크기_구하기(Dictionary <string, StructInfo> structMap, StructInfo structInfo)
        {
            short totalSize = 0;

            foreach (var memberInfo in structInfo.MemberList)
            {
                var typeSize = CheckDataType.CSharpTypeSize(memberInfo.Type);
                if (typeSize > 0)
                {
                    if (memberInfo.ArrayValue <= 1)
                    {
                        totalSize += typeSize;
                    }
                    else
                    {
                        return(typeSize);
                    }
                }
                else
                {
                    if (structMap.ContainsKey(memberInfo.Type))
                    {
                        totalSize += 클래스_데이터_크기_구하기(structMap, structMap[memberInfo.Type]);
                    }
                    else
                    {
                        throw new System.Exception("클래스를 찾을 수 없습니다.");
                    }
                }
            }

            return(totalSize);
        }
        bool IsBasicType(string typeName)
        {
            if (CheckDataType.Is_CppBasicType(typeName))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        void 디코드_멤버데이터_구조체(string indent, Dictionary <string, StructInfo> 구조체정의_사전, StructInfo structInfo, string packetDataName, List <string> GenerateCode)
        {
            int            fieldIndex     = -1;
            MemberDataInfo prevMemberInfo = null;

            foreach (var memberInfo in structInfo.MemberList)
            {
                ++fieldIndex;
                if (fieldIndex > 0)
                {
                    prevMemberInfo = structInfo.MemberList[fieldIndex - 1];
                }

                if (CheckDataType.IsCppNumberType(memberInfo.Type) ||
                    CheckDataType.IsCSharpNumberType(memberInfo.Type)
                    )
                {
                    if (memberInfo.ArrayValue > 1)
                    {
                        디코드_멤버데이터_정수배열(indent, prevMemberInfo, memberInfo, packetDataName, GenerateCode);
                    }
                    else
                    {
                        디코드_멤버데이터_정수(indent, memberInfo, packetDataName, GenerateCode);
                    }
                }
                else if (CheckDataType.IsCppUnicodeCharacterType(memberInfo.Type) ||
                         CheckDataType.IsCSharpCharacterType(memberInfo.Type)
                         )
                {
                    디코드_멤버데이터_문자열(indent, memberInfo, packetDataName, GenerateCode);
                }
                else // 구조체
                {
                    var structInfo2 = 구조체정의_사전[memberInfo.Type];

                    if (memberInfo.ArrayValue <= 1)
                    {
                        var rePacketDataName = string.Format("{0}.{1}", packetDataName, memberInfo.Name);
                        디코드_멤버데이터_구조체(indent, 구조체정의_사전, structInfo2, rePacketDataName, GenerateCode);
                    }
                    else
                    {
                        var rePacketDataName         = string.Format("{0}.{1}[i]", packetDataName, memberInfo.Name);
                        var arrayValuePrevMemberName = prevMemberInfo.Name;

                        GenerateCode.Add(string.Format("{0}for(int i = 0; i < {1}; ++i)", indent, arrayValuePrevMemberName));

                        GenerateCode.Add(indent + "{");
                        디코드_멤버데이터_구조체(indent + "\t", 구조체정의_사전, structInfo2, rePacketDataName, GenerateCode);
                        GenerateCode.Add(indent + "}");
                        GenerateCode.Add("");
                    }
                }
            }
        }