OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [tools/] [src/] [librtcltools/] [RtclGetList.cpp] - Diff between revs 27 and 29

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 27 Rev 29
Line 1... Line 1...
// $Id: RtclGetList.cpp 584 2014-08-22 19:38:12Z mueller $
// $Id: RtclGetList.cpp 631 2015-01-09 21:36:51Z mueller $
//
//
// Copyright 2013-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
//
// This program is free software; you may redistribute and/or modify it under
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
// the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 2, or at your option any later version.
// Software Foundation, either version 2, or at your option any later version.
//
//
Line 11... Line 11...
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for complete details.
// for complete details.
// 
// 
// Revision History: 
// Revision History: 
// Date         Rev Version  Comment
// Date         Rev Version  Comment
 
// 2015-01-08   631   1.1    add Clear(), add '?' (key list) and '*' (kv list)
// 2014-08-22   584   1.0.1  use nullptr
// 2014-08-22   584   1.0.1  use nullptr
// 2013-02-12   487   1.0    Initial version
// 2013-02-12   487   1.0    Initial version
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
 
 
/*!
/*!
  \file
  \file
  \version $Id: RtclGetList.cpp 584 2014-08-22 19:38:12Z mueller $
  \version $Id: RtclGetList.cpp 631 2015-01-09 21:36:51Z mueller $
  \brief   Implemenation of class RtclGetList.
  \brief   Implemenation of class RtclGetList.
*/
*/
 
 
#include <iostream>
#include <iostream>
 
 
#include "librtools/Rexception.hpp"
#include "librtools/Rexception.hpp"
 
 
#include "RtclGet.hpp"
#include "RtclGet.hpp"
#include "RtclGetList.hpp"
#include "RtclGetList.hpp"
 
#include "RtclOPtr.hpp"
 
 
using namespace std;
using namespace std;
 
 
/*!
/*!
  \class Retro::RtclGetList
  \class Retro::RtclGetList
Line 71... Line 73...
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
int RtclGetList::M_get(RtclArgs& args)
void RtclGetList::Clear()
{
{
  string pname;
  fMap.clear();
  if (!args.GetArg("pname", pname)) return TCL_ERROR;
  return;
 
}
 
 
 
//------------------------------------------+-----------------------------------
 
//! FIXME_docs
 
 
 
int RtclGetList::M_get(RtclArgs& args)
 
{
  Tcl_Interp* interp = args.Interp();
  Tcl_Interp* interp = args.Interp();
 
  string pname("*");
 
  if (!args.GetArg("??pname", pname)) return TCL_ERROR;
 
  if (!args.AllDone()) return TCL_ERROR;
 
 
 
  if (pname == "?") {
 
    RtclOPtr rlist(Tcl_NewListObj(0,nullptr));
 
    for (const auto& kv : fMap) {
 
      RtclOPtr pele(Tcl_NewStringObj(kv.first.c_str(), -1));
 
      Tcl_ListObjAppendElement(nullptr, rlist, pele);
 
    }
 
    Tcl_SetObjResult(interp, rlist);
 
    return TCL_OK;
 
 
 
  } else if (pname == "*") {
 
    RtclOPtr rlist(Tcl_NewListObj(0,nullptr));
 
    for (const auto& kv : fMap) {
 
      RtclOPtr pele(Tcl_NewStringObj(kv.first.c_str(), -1));
 
      Tcl_ListObjAppendElement(nullptr, rlist, pele);
 
      Tcl_ListObjAppendElement(nullptr, rlist, kv.second->operator()());
 
    }
 
    Tcl_SetObjResult(interp, rlist);
 
    return TCL_OK;
 
  }
 
 
  map_cit_t it = fMap.lower_bound(pname);
  map_cit_t it = fMap.lower_bound(pname);
 
 
  // complain if not found
  // complain if not found
  if (it == fMap.end() || pname != it->first.substr(0,pname.length())) {
  if (it == fMap.end() || pname != it->first.substr(0,pname.length())) {
    Tcl_AppendResult(interp, "-E: unknown property '", pname.c_str(),
    Tcl_AppendResult(interp, "-E: unknown property '", pname.c_str(),
Line 107... Line 139...
    }
    }
 
 
    return TCL_ERROR;
    return TCL_ERROR;
  }
  }
 
 
  if (!args.AllDone()) return TCL_ERROR;
 
 
 
  args.SetResult((it->second)->operator()());
  args.SetResult((it->second)->operator()());
  return TCL_OK;
  return TCL_OK;
}
}
 
 
} // end namespace Retro
} // end namespace Retro

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.