Example #1
0
        /**
         * バイナリログのログID情報を読み込む
         *
         */
        private LogIDs ReadLogIDsBin(UFileStream fs)
        {
            LogIDs _logIds = new LogIDs();

            // 件数取得
            int size = fs.GetInt32();

            for (int i = 0; i < size; i++)
            {
                // 1件分のログを取得
                LogID logId = new LogID();

                // ID
                logId.ID = fs.GetUInt32();

                // 名前
                logId.Name = fs.GetSizeString();

                // 色
                logId.Color = fs.GetUInt32();

                // アイコン画像名
                // 画像はアイコン画像を読み込んでから設定する
                logId.ImageName = fs.GetSizeString();

                _logIds.Add(logId);
            }

            return(_logIds);
        }
Example #2
0
        /**
         * LogID情報を取得する
         */
        private LogIDs GetLogIDsText(StreamReader sr)
        {
            LogIDs _logIDs = new LogIDs();

            while (!sr.EndOfStream)
            {
                string line = sr.ReadLine().Trim();
                Dictionary <string, string> fields = SplitLineStr(line, ',', ':');

                if (fields.Count == 0)
                {
                    continue;
                }

                // 終了判定
                if (line.Equals("</logid>"))
                {
                    break;
                }

                // レーン情報を取得
                LogID logID = new LogID();

                foreach (KeyValuePair <string, string> kvp in fields)
                {
                    // keyとvalueに分割
                    if (kvp.Value != null)
                    {
                        switch (kvp.Key)
                        {
                        case "id":
                            UInt32 id;
                            if (UInt32.TryParse(kvp.Value, out id))
                            {
                                logID.ID = id;
                            }
                            break;

                        case "name":
                            logID.Name = kvp.Value;
                            break;

                        case "color":
                            // FF001122 のような16進数文字列を整数値に変換
                            logID.Color = Convert.ToUInt32(kvp.Value, 16);
                            break;

                        case "image":
                            logID.Image = images.GetImage(kvp.Value);
                            break;
                        }
                    }
                }
                _logIDs.Add(logID);
            }
            return(_logIDs);
        }
Example #3
0
        /**
         * バイナリログのヘッダ部分を取得
         * @input fs : ファイルオブジェクト
         *
         */
        private void ReadLogHeadBin(UFileStream fs)
        {
            // 文字コードを取得
            string encStr = fs.GetSizeString();

            this.encoding   = UUtility.GetEncodingFromStr(encStr);
            fs.EncodingType = encoding;

            // ログID情報
            logIDs = ReadLogIDsBin(fs);

            // レーン情報
            lanes = ReadLogLanesBin(fs);

            // アイコン画像
            images = ReadLogImagesBin(fs);

            // ログIDの画像を設定する
            foreach (LogID logId in logIDs)
            {
                logId.Image = images.GetImage(logId.ImageName);
            }
        }
Example #4
0
        /**
         * テキスト形式のログファイルを読み込んでメモリに展開する
         * @input inputFilePath: ログファイルのパス
         * @output : true:成功 / false:失敗
         */
        private bool ReadLogFileText(string inputFilePath)
        {
            bool isHeader = false;

            // まずはヘッダ部分からエンコードタイプを取得する
            encoding = GetEncodingText(inputFilePath);

            using (StreamReader sr = new StreamReader(inputFilePath, encoding))
            {
                // データ種別部分をスキップ
                sr.ReadLine();

                // ヘッダ部分を読み込む <head>~</head>
                while (!sr.EndOfStream)
                {
                    // ファイルを 1 行ずつ読み込む
                    string line = sr.ReadLine().Trim();

                    // <head>の行が見つかるまではスキップ
                    if (isHeader == false)
                    {
                        if (line.Equals("<head>"))
                        {
                            isHeader = true;
                        }
                    }
                    else
                    {
                        if (line.Equals("</head>"))
                        {
                            break;
                        }
                        Dictionary <string, string> fields = SplitLineStr(line, ',', ':');

                        // ヘッダーの読み込みメイン
                        switch (line)
                        {
                        case "<lane>":
                            lanes = GetLanesText(sr);
                            break;

                        case "<logid>":
                            logIDs = GetLogIDsText(sr);
                            break;

                        case "<image>":
                            images = GetIconImagesText(sr);
                            break;
                        }
                    }
                }

                // 本体部分を読み込む
                bool isBody = false;
                while (!sr.EndOfStream)
                {
                    // ファイルを 1 行ずつ読み込む
                    string line = sr.ReadLine().Trim();

                    // <body>を見つけたら本体の取得モードに入る
                    if (!isBody)
                    {
                        if (line.Equals("<body>"))
                        {
                            isBody = true;
                        }
                    }
                    else
                    {
                        areaManager = GetLogDataText(sr);
                    }
                }
            }
            return(true);
        }