This is Unofficial EPICS BASE Doxygen Site
FieldName Struct Reference

#include "pvif.h"

Classes

struct  Component
 

Public Types

typedef std::vector< Componentparts_t
 

Public Member Functions

 FieldName ()
 
 FieldName (const std::string &)
 
void swap (FieldName &o)
 
bool empty () const
 
size_t size () const
 
const Componentoperator[] (size_t i) const
 
const Componentback () const
 
epics::pvData::PVFieldPtr lookup (const epics::pvData::PVStructurePtr &S, epics::pvData::PVField **ppenclose) const
 
void show () const
 

Public Attributes

parts_t parts
 

Detailed Description

Definition at line 312 of file pvif.h.

Member Typedef Documentation

typedef std::vector<Component> FieldName::parts_t

Definition at line 323 of file pvif.h.

Constructor & Destructor Documentation

FieldName::FieldName ( )
inline

Definition at line 326 of file pvif.h.

326 {}
FieldName::FieldName ( const std::string &  pv)
explicit

Definition at line 658 of file pdb.cpp.

659 {
660  if(pv.empty())
661  return;
662  Splitter S(pv.c_str(), '.');
663  std::string part;
664  while(S.snip(part)) {
665  if(part.empty())
666  throw std::runtime_error("Empty field component in: "+pv);
667 
668  if(part[part.size()-1]==']') {
669  const size_t open = part.find_last_of('['),
670  N = part.size();
671  bool ok = open!=part.npos;
672  epicsUInt32 index = 0;
673  for(size_t i=open+1; ok && i<(N-1); i++) {
674  ok &= part[i]>='0' && part[i]<='9';
675  index = 10*index + part[i] - '0';
676  }
677  if(!ok)
678  throw std::runtime_error("Invalid field array sub-script in : "+pv);
679 
680  parts.push_back(Component(part.substr(0, open), index));
681 
682  } else {
683  parts.push_back(Component(part));
684  }
685  }
686  if(parts.empty())
687  throw std::runtime_error("Empty field name");
688  if(parts.back().isArray())
689  throw std::runtime_error("leaf field may not have sub-script : "+pv);
690 }
int i
Definition: scan.c:967
parts_t parts
Definition: pvif.h:324
Definition: tool_lib.h:67
unsigned int epicsUInt32
Definition: epicsTypes.h:43

Member Function Documentation

const Component& FieldName::back ( ) const
inline

Definition at line 336 of file pvif.h.

336 { return parts.back(); }
parts_t parts
Definition: pvif.h:324
bool FieldName::empty ( ) const
inline

Definition at line 333 of file pvif.h.

333 { return parts.empty(); }
parts_t parts
Definition: pvif.h:324
epics::pvData::PVFieldPtr FieldName::lookup ( const epics::pvData::PVStructurePtr S,
epics::pvData::PVField **  ppenclose 
) const

Definition at line 693 of file pdb.cpp.

694 {
695  if(ppsar)
696  *ppsar = 0;
697 
698  pvd::PVFieldPtr ret = S;
699  for(size_t i=0, N=parts.size(); i<N; i++) {
700  pvd::PVStructure* parent = dynamic_cast<pvd::PVStructure*>(ret.get());
701  if(!parent)
702  throw std::runtime_error("mid-field is not structure");
703 
704  ret = parent->getSubFieldT(parts[i].name);
705 
706  if(parts[i].isArray()) {
707  pvd::PVStructureArray* sarr = dynamic_cast<pvd::PVStructureArray*>(ret.get());
708  if(!sarr)
709  throw std::runtime_error("indexed field is not structure array");
710 
711  if(ppsar && !*ppsar)
712  *ppsar = sarr;
713 
715 
716  if(V.size()<=parts[i].index || !V[parts[i].index]) {
717  // automatic re-size and ensure non-null
718  V.clear(); // drop our extra ref so that reuse() might avoid a copy
720 
721  if(E.size()<=parts[i].index)
722  E.resize(parts[i].index+1);
723 
724  if(!E[parts[i].index])
725  E[parts[i].index] = pvd::getPVDataCreate()->createPVStructure(sarr->getStructureArray()->getStructure());
726 
727  ret = E[parts[i].index];
728 
729  sarr->replace(pvd::freeze(E));
730 
731  } else {
732  ret = V[parts[i].index];
733  }
734  }
735  }
736  return ret;
737 }
int i
Definition: scan.c:967
StructureArrayConstPtr getStructureArray() const
Definition: pvData.h:1278
parts_t parts
Definition: pvif.h:324
::epics::pvData::shared_vector< PVStructurePtr > svector
Definition: pvData.h:1248
virtual void replace(const const_svector &other) OVERRIDE FINAL
Definition: pvData.h:1299
::epics::pvData::shared_vector< const PVStructurePtr > const_svector
Definition: pvData.h:1249
void clear()
Clear contents. size() becomes 0.
Definition: sharedVector.h:210
Data interface for a structure,.
Definition: pvData.h:712
Data class for a structureArray.
Definition: pvData.h:1236
FORCE_INLINE std::tr1::shared_ptr< PVField > getSubFieldT(A a)
Definition: pvData.h:786
std::tr1::shared_ptr< PVField > PVFieldPtr
Definition: pvData.h:66
virtual const_svector view() const OVERRIDE FINAL
Fetch a read-only view of the current array data.
Definition: pvData.h:1297
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
Definition: pvData.h:1648
const Component& FieldName::operator[] ( size_t  i) const
inline

Definition at line 335 of file pvif.h.

335 { return parts[i]; }
int i
Definition: scan.c:967
parts_t parts
Definition: pvif.h:324
void FieldName::show ( ) const

Definition at line 739 of file pdb.cpp.

740 {
741  if(parts.empty()) {
742  printf("/");
743  return;
744  }
745 
746  bool first = true;
747  for(size_t i=0, N=parts.size(); i<N; i++)
748  {
749  if(!first) {
750  printf(".");
751  } else {
752  first = false;
753  }
754  if(parts[i].isArray())
755  printf("%s[%u]", parts[i].name.c_str(), (unsigned)parts[i].index);
756  else
757  printf("%s", parts[i].name.c_str());
758  }
759 }
int i
Definition: scan.c:967
parts_t parts
Definition: pvif.h:324
#define printf
Definition: epicsStdio.h:41
size_t FieldName::size ( ) const
inline

Definition at line 334 of file pvif.h.

334 { return parts.size(); }
parts_t parts
Definition: pvif.h:324
void FieldName::swap ( FieldName o)
inline

Definition at line 329 of file pvif.h.

329  {
330  parts.swap(o.parts);
331  }
parts_t parts
Definition: pvif.h:324

Member Data Documentation

parts_t FieldName::parts

Definition at line 324 of file pvif.h.


The documentation for this struct was generated from the following files: