crashanalysercmd/Libraries/Engine/CrashItemLib/PluginAPI/FW/CFFTraceLine.cs
author Matti Laitinen <matti.t.laitinen@nokia.com>
Thu, 11 Feb 2010 15:50:58 +0200
changeset 0 818e61de6cd1
permissions -rw-r--r--
Add initial version of Crash Analyser cmdline under EPL

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
* 
* Description:
*
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using SymbianUtils;
using CrashItemLib;

namespace CrashItemLib.PluginAPI
{
    public class CFFTraceLine
    {
        #region Constructors
        public CFFTraceLine( string aLine, long aLineNumber, CFFSource aSource )
		{
            iLine = aLine;
            iLineNumber = aLineNumber;
            iSource = aSource;
        }
        #endregion

        #region API
        public byte[] ToBinary()
        {
            List<byte> ret = new List<byte>();

            // We just want to map the raw unicode character onto a single byte.
            // ASCII range is probably not sufficient (guess?) so this is why we
            // do not use System.Text.ASCIIEncoding, but rather roll our own.
            string line = iLine + System.Environment.NewLine;
            foreach ( char c in line )
            {
                byte b = System.Convert.ToByte( c );
                ret.Add( b );
            }

            return ret.ToArray();
        }
        #endregion

        #region Properties
        public string Line
        {
            get { return iLine; }
        }

        public long LineNumber
        {
            get { return iLineNumber; }
        }

        public CFFSource Descriptor
        {
            get { return iSource; }
        }
        #endregion

        #region Operators
        public static implicit operator string( CFFTraceLine aLine )
        {
            return aLine.Line;
        }
        #endregion

		#region Data members
        private readonly string iLine;
        private readonly long iLineNumber;
        private readonly CFFSource iSource;
        #endregion
    }
}