https://github.com/root-project/root
Raw File
Tip revision: 0afe66dc8a221b5c4a6f9a06c1718b09fb325726 authored by Unknown Author on 25 April 2007, 07:51:34 UTC
This commit was manufactured by cvs2svn to create tag 'v5-15-06'.
Tip revision: 0afe66d
Array.cxx
// @(#)root/reflex:$Name:  $:$Id: Array.cxx,v 1.11 2006/08/03 16:49:21 roiser Exp $
// Author: Stefan Roiser 2004

// Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved.
//
// Permission to use, copy, modify, and distribute this software for any
// purpose is hereby granted without fee, provided that this copyright and
// permissions notice appear in all copies and derivatives.
//
// This software is provided "as is" without express or implied warranty.

#ifndef REFLEX_BUILD
#define REFLEX_BUILD
#endif

#include "Array.h"

#include "Reflex/Type.h"
#include "Reflex/internal/OwnedMember.h"

#include <sstream>

//-------------------------------------------------------------------------------
ROOT::Reflex::Array::Array( const Type & arrayType,
                            size_t len,
                            const std::type_info & typeinfo ) 
//-------------------------------------------------------------------------------
// Constructs an array type.
   : TypeBase( BuildTypeName(arrayType, len ).c_str(), 
               len*(arrayType.SizeOf()), ARRAY, typeinfo ), 
     fArrayType( arrayType ), 
     fLength( len ) { }


//-------------------------------------------------------------------------------
std::string ROOT::Reflex::Array::Name( unsigned int mod ) const {
//-------------------------------------------------------------------------------
// Return the name of the array type.
   return BuildTypeName( fArrayType, fLength, mod );
}


//-------------------------------------------------------------------------------
std::string ROOT::Reflex::Array::BuildTypeName( const Type & typ, 
                                                size_t len,
                                                unsigned int mod ) {
//-------------------------------------------------------------------------------
// Build an array type name.
   std::ostringstream ost; 
   Type t = typ;
   ost << "[" << len << "]";
   while ( t.IsArray() ) {
      ost << "[" << t.ArrayLength() << "]";
      t = t.ToType();
   }
   return t.Name(mod) + ost.str();
}
back to top