예제 #1
0
 public RCCube Fill(RCCube source)
 {
     _source = source;
     for (int i = 0; i < source.Cols; ++i)
     {
         _target.ReserveColumn(source.ColumnAt(i), canonical: false);
     }
     _source.VisitCellsCanonical(this, 0, _source.Axis.Count);
     return(_target);
 }
예제 #2
0
 public RCCube Unplug(RCCube source)
 {
     _source = source;
     _unplug = true;
     for (int i = 0; i < _source.Cols; ++i)
     {
         _target.ReserveColumn(_source.ColumnAt(i));
     }
     _source.VisitCellsCanonical(this, 0, _source.Axis.Count);
     return(_target);
 }
예제 #3
0
 public RCCube Plug(RCCube source)
 {
     _source = source;
     _source.VisitCellsCanonical(this, 0, _source.Axis.Count);
     return(_target);
 }
예제 #4
0
        public void Format(RCCube source)
        {
            if (source.Count == 0)
            {
                if (_args.Syntax == "RCL")
                {
                    _builder.Append("[]");
                }
                return;
            }
            _names     = new List <string> ();
            _columns   = new List <List <string> > ();
            _max       = new List <int> ();
            _leftAlign = new List <bool> ();
            int  tcols    = 0;
            bool useGRows = false;

            if (source.Axis.Has("G") && _args.Showt)
            {
                _names.Add("G");
                _columns.Add(new List <string> ());
                _max.Add(MIN_WIDTH);
                _leftAlign.Add(false);
                ++tcols;
                useGRows = true;
            }
            if (source.Axis.Has("E") && _args.Showt)
            {
                _names.Add("E");
                _columns.Add(new List <string> ());
                _max.Add(MIN_WIDTH);
                _leftAlign.Add(false);
                ++tcols;
            }
            if (source.Axis.Has("T") && _args.Showt)
            {
                _names.Add("T");
                _columns.Add(new List <string> ());
                _max.Add(MIN_WIDTH);
                _leftAlign.Add(false);
                ++tcols;
            }
            if (source.Axis.Has("S"))
            {
                _names.Add("S");
                _columns.Add(new List <string> ());
                _max.Add(MIN_WIDTH);
                _leftAlign.Add(true);
                ++tcols;
            }
            for (int i = 0; i < source.Cols; ++i)
            {
                string name = source.ColumnAt(i);
                char   type = source.GetTypeCode(name);
                _names.Add(source.NameAt(i));
                _columns.Add(new List <string> ());
                _max.Add(MIN_WIDTH);
                _leftAlign.Add(type == 'y' || type == 's');
            }
            // Populate _columns and _max.
            if (_args.CanonicalCubes)
            {
                source.VisitCellsCanonical(this, 0, source.Axis.Count);
            }
            else
            {
                source.VisitCellsForward(this, 0, source.Axis.Count);
            }
            if (_args.Syntax == "RCL")
            {
                FormatRC(tcols);
            }
            else if (_args.Syntax == "HTML")
            {
                FormatHtml(tcols, useGRows);
            }
            else if (_args.Syntax == "CSV")
            {
                FormatCsv(tcols, useGRows, CSV_ESCAPE_CHARS, true);
            }
            else if (_args.Syntax == "LOG")
            {
                FormatCsv(tcols, useGRows, LOG_ESCAPE_CHARS, false);
            }
            else
            {
                throw new Exception("Unknown syntax for format:" + _args.Syntax);
            }
        }