pva2pva 1.4.2
Loading...
Searching...
No Matches
FieldName Struct Reference

Classes

struct  Component

Public Types

typedef std::vector< Component > parts_t

Public Member Functions

 FieldName (const std::string &)
void swap (FieldName &o)
bool empty () const
size_t size () const
const Component & operator[] (size_t i) const
const Component & back () 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 322 of file pvif.h.

Member Typedef Documentation

◆ parts_t

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

Definition at line 333 of file pvif.h.

Constructor & Destructor Documentation

◆ FieldName() [1/2]

FieldName::FieldName ( )
inline

Definition at line 336 of file pvif.h.

336{}

◆ FieldName() [2/2]

FieldName::FieldName ( const std::string & pv)
explicit

Definition at line 722 of file pdb.cpp.

723{
724 if(pv.empty())
725 return;
726 Splitter S(pv.c_str(), '.');
727 std::string part;
728 while(S.snip(part)) {
729 if(part.empty())
730 throw std::runtime_error("Empty field component in: "+pv);
731
732 if(part[part.size()-1]==']') {
733 const size_t open = part.find_last_of('['),
734 N = part.size();
735 bool ok = open!=part.npos;
736 epicsUInt32 index = 0;
737 for(size_t i=open+1; ok && i<(N-1); i++) {
738 ok &= part[i]>='0' && part[i]<='9';
739 index = 10*index + part[i] - '0';
740 }
741 if(!ok)
742 throw std::runtime_error("Invalid field array sub-script in : "+pv);
743
744 parts.push_back(Component(part.substr(0, open), index));
745
746 } else {
747 parts.push_back(Component(part));
748 }
749 }
750 if(parts.empty())
751 throw std::runtime_error("Empty field name");
752}

Member Function Documentation

◆ back()

const Component & FieldName::back ( ) const
inline

Definition at line 346 of file pvif.h.

346{ return parts.back(); }

◆ empty()

bool FieldName::empty ( ) const
inline

Definition at line 343 of file pvif.h.

343{ return parts.empty(); }

◆ lookup()

epics::pvData::PVFieldPtr FieldName::lookup ( const epics::pvData::PVStructurePtr & S,
epics::pvData::PVField ** ppenclose ) const

Definition at line 755 of file pdb.cpp.

756{
757 if(ppsar)
758 *ppsar = 0;
759
760 pvd::PVFieldPtr ret = S;
761 for(size_t i=0, N=parts.size(); i<N; i++) {
762 pvd::PVStructure* parent = dynamic_cast<pvd::PVStructure*>(ret.get());
763 if(!parent)
764 throw std::runtime_error("mid-field is not structure");
765
766 ret = parent->getSubFieldT(parts[i].name);
767
768 if(parts[i].isArray()) {
769 pvd::PVStructureArray* sarr = dynamic_cast<pvd::PVStructureArray*>(ret.get());
770 if(!sarr)
771 throw std::runtime_error("indexed field is not structure array");
772
773 if(ppsar && !*ppsar)
774 *ppsar = sarr;
775
776 pvd::PVStructureArray::const_svector V(sarr->view());
777
778 if(V.size()<=parts[i].index || !V[parts[i].index]) {
779 // automatic re-size and ensure non-null
780 V.clear(); // drop our extra ref so that reuse() might avoid a copy
781 pvd::PVStructureArray::svector E(sarr->reuse());
782
783 if(E.size()<=parts[i].index)
784 E.resize(parts[i].index+1);
785
786 if(!E[parts[i].index])
787 E[parts[i].index] = pvd::getPVDataCreate()->createPVStructure(sarr->getStructureArray()->getStructure());
788
789 ret = E[parts[i].index];
790
791 sarr->replace(pvd::freeze(E));
792
793 } else {
794 ret = V[parts[i].index];
795 }
796 }
797 }
798 return ret;
799}

◆ operator[]()

const Component & FieldName::operator[] ( size_t i) const
inline

Definition at line 345 of file pvif.h.

345{ return parts[i]; }

◆ show()

void FieldName::show ( ) const

Definition at line 801 of file pdb.cpp.

802{
803 if(parts.empty()) {
804 printf("/");
805 return;
806 }
807
808 bool first = true;
809 for(size_t i=0, N=parts.size(); i<N; i++)
810 {
811 if(!first) {
812 printf(".");
813 } else {
814 first = false;
815 }
816 if(parts[i].isArray())
817 printf("%s[%u]", parts[i].name.c_str(), (unsigned)parts[i].index);
818 else
819 printf("%s", parts[i].name.c_str());
820 }
821}

◆ size()

size_t FieldName::size ( ) const
inline

Definition at line 344 of file pvif.h.

344{ return parts.size(); }

◆ swap()

void FieldName::swap ( FieldName & o)
inline

Definition at line 339 of file pvif.h.

339 {
340 parts.swap(o.parts);
341 }

Member Data Documentation

◆ parts

parts_t FieldName::parts

Definition at line 334 of file pvif.h.


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