LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
ast::XmlChan Class Reference

XmlChan provides input/output of AST objects. More...

#include <XmlChan.h>

Inheritance diagram for ast::XmlChan:
ast::Channel ast::Object

Public Types

using ObjectPtr = std::unique_ptr<AstObject, Deleter>
 unique pointer holding an AST raw pointer
 

Public Member Functions

 XmlChan (Stream &stream, std::string const &options="")
 Construct a channel that uses a provided Stream.
 
virtual ~XmlChan ()
 
 XmlChan (XmlChan const &)=delete
 
 XmlChan (XmlChan &&)=default
 
XmlChanoperator= (XmlChan const &)=delete
 
XmlChanoperator= (XmlChan &&)=default
 
std::string getXmlFormat () const
 Get XmlFormat System for formatting Objects as XML.
 
int getXmlLength () const
 Get XmlLength: controls output buffer length.
 
std::string getXmlPrefix ()
 Get XmlPrefix: the namespace prefix to use when writing.
 
void setXmlFormat (std::string const &format)
 Set XmlFormat System for formatting Objects as XML.
 
void setXmlLength (int len)
 Set XmlLength: controls output buffer length; 0 for no limit.
 
void setXmlPrefix (std::string const &prefix)
 Set XmlPrefix: the namespace prefix to use when writing.
 
std::shared_ptr< Channelcopy () const
 Return a deep copy of this object.
 
bool getComment () const
 Get Comment: include textual comments in output?
 
int getFull () const
 Get Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose.
 
int getIndent () const
 Get Indent: indentation increment between objects.
 
int getReportLevel () const
 Get ReportLevel: report level.
 
bool getSkip () const
 Get Skip: skip irrelevant data on input?
 
bool getStrict () const
 Get Strict: generate errors instead of warnings?
 
std::shared_ptr< Objectread ()
 Read an object from a channel.
 
void setComment (bool skip)
 Set Comment: include textual comments in output?
 
void setFull (int full)
 Set Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose.
 
void setIndent (int indent)
 Set Indent: indentation increment between objects.
 
void setReportLevel (int level)
 Set ReportLevel: report level; an integer in the range [0, 3] where 0 is the most verbose.
 
void setSkip (bool skip)
 Set Skip: skip irrelevant data on input?
 
void setStrict (bool strict)
 Set Strict: generate errors instead of warnings?
 
KeyMap warnings () const
 Return a KeyMap holding the text of any warnings issued as a result of the previous invocation of read or write.
 
int write (Object const &object)
 Write an object to a channel.
 
bool operator== (Object const &rhs) const
 Return True if this and rhs are the equal.
 
bool operator!= (Object const &rhs) const
 Return True if this and rhs are not equal.
 
void clear (std::string const &attrib)
 Clear the values of a specified set of attributes for an Object.
 
bool hasAttribute (std::string const &attrib) const
 Does this object have an attribute with the specified name?
 
std::string getClassName () const
 Get Class: the name of the class (e.g.
 
std::string getID () const
 Get ID: object identification string that is not copied.
 
std::string getIdent () const
 Get Ident: object identification string that is copied.
 
int getNObject () const
 Get NObject: number of AST objects in existence of the same type as the underlying AST class.
 
int getObjSize () const
 Get ObjSize: the in-memory size of the AST object in bytes.
 
int getRefCount () const
 Get RefCount: number of active pointers to the underlying AST object.
 
bool getUseDefs () const
 Get UseDefs: allow use of default values for Object attributes?
 
void lock (bool wait)
 Lock this object for exclusive use by the calling thread.
 
bool same (Object const &other) const
 Does this contain the same AST object as another?
 
void setID (std::string const &id)
 Set ID: object identification string that is not copied.
 
void setIdent (std::string const &ident)
 Set Ident: object identification string that is copied.
 
void setUseDefs (bool usedefs)
 Set UseDefs: allow use of default values for Object attributes?
 
void show (std::ostream &os, bool showComments=true) const
 Print a textual description the object to an ostream.
 
std::string show (bool showComments=true) const
 Return a textual description the object as a string.
 
bool test (std::string const &attrib) const
 Has this attribute been explicitly set (and not subsequently cleared)?
 
void unlock (bool report=false)
 Unlock this object previously locked using lock, so that other threads can use this object.
 
AstObject const * getRawPtr () const
 Get the raw AST pointer.
 
AstObject * getRawPtr ()
 Get the raw AST pointer.
 

Static Public Member Functions

static std::shared_ptr< ObjectfromString (std::string const &str)
 Construct an Object from a string, using astFromString.
 
template<typename Class >
static std::shared_ptr< Class > fromAstObject (AstObject *rawObj, bool copy)
 Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type.
 

Protected Member Functions

virtual std::shared_ptr< ObjectcopyPolymorphic () const override
 Return a deep copy of this object.
 
template<typename T , typename AstT >
std::shared_ptr< T > copyImpl () const
 Implementation of deep copy.
 
bool getB (std::string const &attrib) const
 Get the value of an attribute as a bool.
 
std::string const getC (std::string const &attrib) const
 Get the value of an attribute as a string.
 
double getD (std::string const &attrib) const
 Get the value of an attribute as a double.
 
float getF (std::string const &attrib) const
 Get the value of an attribute as a float.
 
int getI (std::string const &attrib) const
 Get the value of an attribute as an int.
 
long int getL (std::string const &attrib) const
 Get the value of an attribute as a long int.
 
void set (std::string const &setting)
 Assign a set of attribute values, over-riding any previous values.
 
void setB (std::string const &attrib, bool value)
 Set the value of an attribute as a bool.
 
void setC (std::string const &attrib, std::string const &value)
 Set the value of an attribute as a string.
 
void setD (std::string const &attrib, double value)
 Set the value of an attribute as a double.
 
void setF (std::string const &attrib, float value)
 Set the value of an attribute as a float.
 
void setI (std::string const &attrib, int value)
 Set the value of an attribute as an int.
 
void setL (std::string const &attrib, long int value)
 Set the value of an attribute as a long int.
 

Static Protected Member Functions

template<typename ShimT , typename AstT >
static std::shared_ptr< ShimT > makeShim (AstObject *p)
 Functor to make an astshim instance from a raw AST pointer of the corresponding type.
 

Detailed Description

XmlChan provides input/output of AST objects.

Writing an Object to a XmlChan will generate a textual representation of that Object, and reading from a XmlChan will create a new Object from its textual representation.

XmlChan provides the following attributes, in addition to those provided by Channel and Object

XmlFormat: system for formatting Objects as XML. XmlLength: controls output buffer length; 0 for no limit. XmlPrefix: the namespace prefix to use when writing.

Definition at line 46 of file XmlChan.h.

Member Typedef Documentation

◆ ObjectPtr

using ast::Object::ObjectPtr = std::unique_ptr<AstObject, Deleter>
inherited

unique pointer holding an AST raw pointer

Definition at line 59 of file Object.h.

Constructor & Destructor Documentation

◆ XmlChan() [1/3]

ast::XmlChan::XmlChan ( Stream & stream,
std::string const & options = "" )
inlineexplicit

Construct a channel that uses a provided Stream.

Parameters
[in]streamStream for channel I/O:
[in]optionsComma-separated list of attribute assignments.

Definition at line 58 of file XmlChan.h.

59 : Channel(reinterpret_cast<AstChannel *>(
60 astXmlChan(detail::source, detail::sink, "%s", options.c_str())),
61 stream) {
62 assertOK();
63 }
Channel(Stream &stream, std::string const &options="")
Construct a channel that uses a provided Stream.
Definition Channel.cc:31
const char * source()
Source function that allows astChannel to source from a Stream.
Definition Stream.h:224
void sink(const char *cstr)
Sink function that allows astChannel to sink to a Stream.
Definition Stream.h:239
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST's state is bad.
Definition base.cc:49

◆ ~XmlChan()

virtual ast::XmlChan::~XmlChan ( )
inlinevirtual

Definition at line 65 of file XmlChan.h.

65{}

◆ XmlChan() [2/3]

ast::XmlChan::XmlChan ( XmlChan const & )
delete

◆ XmlChan() [3/3]

ast::XmlChan::XmlChan ( XmlChan && )
default

Member Function Documentation

◆ clear()

void ast::Object::clear ( std::string const & attrib)
inlineinherited

Clear the values of a specified set of attributes for an Object.

Clearing an attribute cancels any value that has previously been explicitly set for it, so that the standard default attribute value will subsequently be used instead. This also causes the astTest function to return the value zero for the attribute, indicating that no value has been set.

Definition at line 119 of file Object.h.

119 {
120 astClear(getRawPtr(), attrib.c_str());
121 assertOK();
122 }
AstObject const * getRawPtr() const
Get the raw AST pointer.
Definition Object.h:292

◆ copy()

std::shared_ptr< Channel > ast::Channel::copy ( ) const
inlineinherited

Return a deep copy of this object.

Definition at line 84 of file Channel.h.

84 {
85 throw std::logic_error(
86 "Channel cannot be deep copied because its contained stream cannot be deep copied");
87 }

◆ copyImpl()

template<typename T , typename AstT >
std::shared_ptr< T > ast::Object::copyImpl ( ) const
inlineprotectedinherited

Implementation of deep copy.

Should be called to implement copyPolymorphic by all derived classes.

Definition at line 320 of file Object.h.

320 {
321 auto *rawptr = reinterpret_cast<AstT *>(astCopy(getRawPtr()));
322 auto retptr = std::shared_ptr<T>(new T(rawptr));
323 assertOK();
324 return retptr;
325 }

◆ copyPolymorphic()

virtual std::shared_ptr< Object > ast::Channel::copyPolymorphic ( ) const
inlineoverrideprotectedvirtualinherited

Return a deep copy of this object.

This is called by copy.

Each subclass must override this method. The standard implementation is:

return copyImpl<astshim_class, ast_class>();

for example Frame implements this as:

return copyImpl<Frame, AstFrame>();

Implements ast::Object.

Definition at line 159 of file Channel.h.

159{ return std::shared_ptr<Object>(); }

◆ fromAstObject()

template<typename Class >
template std::shared_ptr< Object > ast::Object::fromAstObject< Object > ( AstObject * rawObj,
bool copy )
staticinherited

Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type.

The returned object takes ownership of the pointer. This is almost always what you want, for instance astDecompose returns shallow copies of the internal pointers.

Template Parameters
ClassThe class of the returned shared pointer. (The actual class will be the correct class of rawPtr.)
Parameters
[in]rawObjA bare AST object pointer
[in]copyIf True then make a deep copy of the pointer (and free the original)

Definition at line 138 of file Object.cc.

138 {
139 AstObject *rawObjCopy = rawObj;
140 if (copy) {
141 rawObjCopy = reinterpret_cast<AstObject *>(astCopy(rawObj));
142 astAnnul(rawObj);
143 }
144 assertOK(rawObjCopy);
145
146 // Make the appropriate ast shim object and dynamically cast to the desired output type
147 auto retObjectBeforeCast = Object::_basicFromAstObject(rawObjCopy);
148 auto retObject = std::dynamic_pointer_cast<Class>(retObjectBeforeCast);
149 if (!retObject) {
151 os << "The component is of type " << retObject->getClassName()
152 << ", which could not be cast to the desired type " << typeid(Class).name();
153 throw std::runtime_error(os.str());
154 }
155 return retObject;
156}
table::Key< std::string > name
Definition Amplifier.cc:116
std::ostream * os
Definition Schema.cc:557

◆ fromString()

static std::shared_ptr< Object > ast::Object::fromString ( std::string const & str)
inlinestaticinherited

Construct an Object from a string, using astFromString.

Definition at line 88 of file Object.h.

88 {
89 auto *rawPtr = reinterpret_cast<AstObject *>(astFromString(str.c_str()));
90 assertOK(rawPtr);
91 return Object::_basicFromAstObject(rawPtr);
92 }

◆ getB()

bool ast::Object::getB ( std::string const & attrib) const
inlineprotectedinherited

Get the value of an attribute as a bool.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 348 of file Object.h.

348 {
349 bool val = astGetI(getRawPtr(), attrib.c_str());
350 assertOK();
351 return val;
352 }
ImageT val
Definition CR.cc:146

◆ getC()

std::string const ast::Object::getC ( std::string const & attrib) const
inlineprotectedinherited

Get the value of an attribute as a string.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 361 of file Object.h.

361 {
362 char const *rawval = astGetC(getRawPtr(), attrib.c_str());
363 assertOK();
364 return std::string(rawval);
365 }

◆ getClassName()

std::string ast::Object::getClassName ( ) const
inlineinherited

Get Class: the name of the class (e.g.

ZoomMap)

Note: if AST returns "CmpMap" then the name will be changed to "SeriesMap" or "ParallelMap", as appropriate.

Definition at line 139 of file Object.h.

139{ return detail::getClassName(getRawPtr()); }
std::string getClassName(AstObject const *rawObj)
Get the AST class name, changing CmpMap to SeriesMap or ParallelMap as appropriate.
Definition utils.cc:37

◆ getComment()

bool ast::Channel::getComment ( ) const
inlineinherited

Get Comment: include textual comments in output?

Definition at line 90 of file Channel.h.

90{ return getB("Comment"); }
bool getB(std::string const &attrib) const
Get the value of an attribute as a bool.
Definition Object.h:348

◆ getD()

double ast::Object::getD ( std::string const & attrib) const
inlineprotectedinherited

Get the value of an attribute as a double.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 374 of file Object.h.

374 {
375 double val = astGetD(getRawPtr(), attrib.c_str());
376 assertOK();
377 return val;
378 }

◆ getF()

float ast::Object::getF ( std::string const & attrib) const
inlineprotectedinherited

Get the value of an attribute as a float.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 387 of file Object.h.

387 {
388 float val = astGetF(getRawPtr(), attrib.c_str());
389 assertOK();
390 return val;
391 }

◆ getFull()

int ast::Channel::getFull ( ) const
inlineinherited

Get Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose.

Definition at line 93 of file Channel.h.

93{ return getI("Full"); }
int getI(std::string const &attrib) const
Get the value of an attribute as an int.
Definition Object.cc:178

◆ getI()

int ast::Object::getI ( std::string const & attrib) const
protectedinherited

Get the value of an attribute as an int.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 178 of file Object.cc.

178 {
179 int val = astGetI(getRawPtr(), attrib.c_str());
180 assertOK();
181 return val;
182}

◆ getID()

std::string ast::Object::getID ( ) const
inlineinherited

Get ID: object identification string that is not copied.

Definition at line 142 of file Object.h.

142{ return getC("ID"); }
std::string const getC(std::string const &attrib) const
Get the value of an attribute as a string.
Definition Object.h:361

◆ getIdent()

std::string ast::Object::getIdent ( ) const
inlineinherited

Get Ident: object identification string that is copied.

Definition at line 145 of file Object.h.

145{ return getC("Ident"); }

◆ getIndent()

int ast::Channel::getIndent ( ) const
inlineinherited

Get Indent: indentation increment between objects.

Definition at line 96 of file Channel.h.

96{ return getB("Indent"); }

◆ getL()

long int ast::Object::getL ( std::string const & attrib) const
inlineprotectedinherited

Get the value of an attribute as a long int.

If possible, the attribute value is converted to the type you request.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 409 of file Object.h.

409 {
410 long int val = astGetL(getRawPtr(), attrib.c_str());
411 assertOK();
412 return val;
413 }

◆ getNObject()

int ast::Object::getNObject ( ) const
inlineinherited

Get NObject: number of AST objects in existence of the same type as the underlying AST class.

Warning
Intended only for debugging astshim.

Definition at line 153 of file Object.h.

153{ return getI("NObject"); }

◆ getObjSize()

int ast::Object::getObjSize ( ) const
inlineinherited

Get ObjSize: the in-memory size of the AST object in bytes.

Definition at line 156 of file Object.h.

156{ return getI("ObjSize"); }

◆ getRawPtr() [1/2]

AstObject * ast::Object::getRawPtr ( )
inlineinherited

Get the raw AST pointer.

Intended for internal use only, but cannot be made protected without endless "friend class" declarations.

Definition at line 294 of file Object.h.

294{ return &*_objPtr; };

◆ getRawPtr() [2/2]

AstObject const * ast::Object::getRawPtr ( ) const
inlineinherited

Get the raw AST pointer.

Intended for internal use only, but cannot be made protected without endless "friend class" declarations.

Definition at line 292 of file Object.h.

292{ return &*_objPtr; };

◆ getRefCount()

int ast::Object::getRefCount ( ) const
inlineinherited

Get RefCount: number of active pointers to the underlying AST object.

Warning
Intended only for debugging astshim.

Definition at line 163 of file Object.h.

163{ return getI("RefCount"); }

◆ getReportLevel()

int ast::Channel::getReportLevel ( ) const
inlineinherited

Get ReportLevel: report level.

Definition at line 99 of file Channel.h.

99{ return getI("ReportLevel"); }

◆ getSkip()

bool ast::Channel::getSkip ( ) const
inlineinherited

Get Skip: skip irrelevant data on input?

Definition at line 102 of file Channel.h.

102{ return getB("Skip"); }

◆ getStrict()

bool ast::Channel::getStrict ( ) const
inlineinherited

Get Strict: generate errors instead of warnings?

Definition at line 105 of file Channel.h.

105{ return getB("Strict"); }

◆ getUseDefs()

bool ast::Object::getUseDefs ( ) const
inlineinherited

Get UseDefs: allow use of default values for Object attributes?

Definition at line 166 of file Object.h.

166{ return getB("UseDefs"); }

◆ getXmlFormat()

std::string ast::XmlChan::getXmlFormat ( ) const
inline

Get XmlFormat System for formatting Objects as XML.

Definition at line 73 of file XmlChan.h.

73{ return getC("XmlFormat"); }

◆ getXmlLength()

int ast::XmlChan::getXmlLength ( ) const
inline

Get XmlLength: controls output buffer length.

Definition at line 76 of file XmlChan.h.

76{ return getI("XmlLength"); }

◆ getXmlPrefix()

std::string ast::XmlChan::getXmlPrefix ( )
inline

Get XmlPrefix: the namespace prefix to use when writing.

Definition at line 79 of file XmlChan.h.

79{ return getC("XmlPrefix"); }

◆ hasAttribute()

bool ast::Object::hasAttribute ( std::string const & attrib) const
inlineinherited

Does this object have an attribute with the specified name?

Definition at line 127 of file Object.h.

127 {
128 bool ret = astHasAttribute(getRawPtr(), attrib.c_str());
129 assertOK();
130 return ret;
131 }

◆ lock()

void ast::Object::lock ( bool wait)
inlineinherited

Lock this object for exclusive use by the calling thread.

The thread-safe public interface to AST is designed so that an error is reported if any thread attempts to use an Object that it has not previously locked for its own exclusive use using this function. When an Object is created, it is initially locked by the thread that creates it, so newly created objects do not need to be explicitly locked. However, if an Object pointer is passed to another thread, the original thread must first unlock it (using astUnlock) and the new thread must then lock it (using astLock) before the new thread can use the Object.

Parameters
[in]waitIf the Object is curently locked by another thread then this function will either report an error or block. If a non-zero value is supplied for "wait", the calling thread waits until the object is available for it to use. Otherwise, an error is reported and the function returns immediately without locking the Object.

Notes

  • The Locked object will belong to the current AST context.
  • This function returns without action if the Object is already locked by the calling thread.
  • If simultaneous use of the same object is required by two or more threads, Object::copy should be used to to produce a deep copy of the Object for each thread. Each copy should then be unlocked by the parent thread (i.e. the thread that created the copy), and then locked by the child thread (i.e. the thread that wants to use the copy).
  • This function returns without action if the AST library has been built without POSIX thread support (i.e. the "-with-pthreads" option was not specified when running the "configure" script).

Definition at line 202 of file Object.h.

202 {
203 astLock(getRawPtr(), static_cast<int>(wait));
204 assertOK();
205 }

◆ makeShim()

template<typename ShimT , typename AstT >
static std::shared_ptr< ShimT > ast::Object::makeShim ( AstObject * p)
inlinestaticprotectedinherited

Functor to make an astshim instance from a raw AST pointer of the corresponding type.

Template Parameters
ShimTOutput astshim class
AstTOutput AST class

Definition at line 310 of file Object.h.

310 {
311 return std::shared_ptr<ShimT>(new ShimT(reinterpret_cast<AstT *>(p)));
312 }

◆ operator!=()

bool ast::Object::operator!= ( Object const & rhs) const
inlineinherited

Return True if this and rhs are not equal.

See operator== for details

Definition at line 82 of file Object.h.

82 {
83 return !(*this == rhs); };

◆ operator=() [1/2]

XmlChan & ast::XmlChan::operator= ( XmlChan && )
default

◆ operator=() [2/2]

XmlChan & ast::XmlChan::operator= ( XmlChan const & )
delete

◆ operator==()

bool ast::Object::operator== ( Object const & rhs) const
inherited

Return True if this and rhs are the equal.

For two objects be equal, they both must have the same attributes and all contained objects must be equal.

Definition at line 85 of file Object.cc.

85 {
86 auto thisStr = this->show(false);
87 auto rhsStr = rhs.show(false);
88 return rhsStr == thisStr;
89}
void show(std::ostream &os, bool showComments=true) const
Print a textual description the object to an ostream.
Definition Object.cc:158

◆ read()

std::shared_ptr< Object > ast::Channel::read ( )
inherited

Read an object from a channel.

Definition at line 52 of file Channel.cc.

52 {
53 AstObject *rawRet = reinterpret_cast<AstObject *>(astRead(getRawPtr()));
54 assertOK(rawRet);
55 if (!rawRet) {
56 throw std::runtime_error("Could not read an AST object from this channel");
57 }
58 return Object::fromAstObject<Object>(rawRet, false);
59}

◆ same()

bool ast::Object::same ( Object const & other) const
inlineinherited

Does this contain the same AST object as another?

This is a test of identity, not of equality.

Definition at line 212 of file Object.h.

212{ return astSame(getRawPtr(), other.getRawPtr()); }

◆ set()

void ast::Object::set ( std::string const & setting)
inlineprotectedinherited

Assign a set of attribute values, over-riding any previous values.

The attributes and their new values are specified via a character string, which should contain a comma-separated list of the form: "attribute_1 = value_1, attribute_2 = value_2, ... " where "attribute_n" specifies an attribute name, and the value to the right of each " =" sign should be a suitable textual representation of the value to be assigned. This value will be interpreted according to the attribute's data type.

Notes

  • Attribute names are not case sensitive and may be surrounded by white space
  • Attribute names are not case sensitive and may be surrounded by white space.
  • White space may also surround attribute values, where it will generally be ignored (except for string-valued attributes where it is significant and forms part of the value to be assigned).
  • To include a literal comma or percent sign in the value assigned to an attribute, the whole attribute value should be enclosed in quotation markes.
Exceptions
std::runtime_errorif the attribute is read-only

Definition at line 436 of file Object.h.

436 {
437 astSet(getRawPtr(), "%s", setting.c_str());
438 assertOK();
439 }

◆ setB()

void ast::Object::setB ( std::string const & attrib,
bool value )
inlineprotectedinherited

Set the value of an attribute as a bool.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 448 of file Object.h.

448 {
449 astSetI(getRawPtr(), attrib.c_str(), value);
450 assertOK();
451 }

◆ setC()

void ast::Object::setC ( std::string const & attrib,
std::string const & value )
inlineprotectedinherited

Set the value of an attribute as a string.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 460 of file Object.h.

460 {
461 astSetC(getRawPtr(), attrib.c_str(), value.c_str());
462 assertOK();
463 }

◆ setComment()

void ast::Channel::setComment ( bool skip)
inlineinherited

Set Comment: include textual comments in output?

Definition at line 111 of file Channel.h.

111{ setB("Comment", skip); }
void setB(std::string const &attrib, bool value)
Set the value of an attribute as a bool.
Definition Object.h:448

◆ setD()

void ast::Object::setD ( std::string const & attrib,
double value )
inlineprotectedinherited

Set the value of an attribute as a double.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 472 of file Object.h.

472 {
473 astSetD(getRawPtr(), attrib.c_str(), value);
474 assertOK();
475 }

◆ setF()

void ast::Object::setF ( std::string const & attrib,
float value )
inlineprotectedinherited

Set the value of an attribute as a float.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 484 of file Object.h.

484 {
485 astSetF(getRawPtr(), attrib.c_str(), value);
486 assertOK();
487 }

◆ setFull()

void ast::Channel::setFull ( int full)
inlineinherited

Set Full: level of output detail; one of -1: minimum, 0: normal, 1: verbose.

Definition at line 114 of file Channel.h.

114{ setI("Full", full); }
void setI(std::string const &attrib, int value)
Set the value of an attribute as an int.
Definition Object.h:496

◆ setI()

void ast::Object::setI ( std::string const & attrib,
int value )
inlineprotectedinherited

Set the value of an attribute as an int.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 496 of file Object.h.

496 {
497 astSetI(getRawPtr(), attrib.c_str(), value);
498 assertOK();
499 }

◆ setID()

void ast::Object::setID ( std::string const & id)
inlineinherited

Set ID: object identification string that is not copied.

Definition at line 215 of file Object.h.

215{ setC("ID", id); }
void setC(std::string const &attrib, std::string const &value)
Set the value of an attribute as a string.
Definition Object.h:460

◆ setIdent()

void ast::Object::setIdent ( std::string const & ident)
inlineinherited

Set Ident: object identification string that is copied.

Definition at line 218 of file Object.h.

218{ setC("Ident", ident); }

◆ setIndent()

void ast::Channel::setIndent ( int indent)
inlineinherited

Set Indent: indentation increment between objects.

Definition at line 117 of file Channel.h.

117{ setI("Indent", indent); }

◆ setL()

void ast::Object::setL ( std::string const & attrib,
long int value )
inlineprotectedinherited

Set the value of an attribute as a long int.

If possible, the type you provide is converted to the actual type of the attribute.

Exceptions
std::runtime_errorif the attribute does not exist or the value cannot be converted

Definition at line 508 of file Object.h.

508 {
509 astSetL(getRawPtr(), attrib.c_str(), value);
510 assertOK();
511 }

◆ setReportLevel()

void ast::Channel::setReportLevel ( int level)
inlineinherited

Set ReportLevel: report level; an integer in the range [0, 3] where 0 is the most verbose.

Exceptions
std::invalid_argumentif level is not in range [0, 3]

Definition at line 125 of file Channel.h.

125 {
126 if ((level < 0) || (level > 3)) {
128 os << "level = " << level << " not in range [0, 3]";
129 throw std::invalid_argument(os.str());
130 }
131 setI("ReportLevel", level);
132 }

◆ setSkip()

void ast::Channel::setSkip ( bool skip)
inlineinherited

Set Skip: skip irrelevant data on input?

Definition at line 135 of file Channel.h.

135{ setB("Skip", skip); }

◆ setStrict()

void ast::Channel::setStrict ( bool strict)
inlineinherited

Set Strict: generate errors instead of warnings?

Definition at line 138 of file Channel.h.

138{ setB("Strict", strict); }

◆ setUseDefs()

void ast::Object::setUseDefs ( bool usedefs)
inlineinherited

Set UseDefs: allow use of default values for Object attributes?

Definition at line 221 of file Object.h.

221{ setB("UseDefs", usedefs); }

◆ setXmlFormat()

void ast::XmlChan::setXmlFormat ( std::string const & format)
inline

Set XmlFormat System for formatting Objects as XML.

Definition at line 82 of file XmlChan.h.

82{ setC("XmlFormat", format); }

◆ setXmlLength()

void ast::XmlChan::setXmlLength ( int len)
inline

Set XmlLength: controls output buffer length; 0 for no limit.

Definition at line 85 of file XmlChan.h.

85{ setI("XmlLength", len); }

◆ setXmlPrefix()

void ast::XmlChan::setXmlPrefix ( std::string const & prefix)
inline

Set XmlPrefix: the namespace prefix to use when writing.

Definition at line 88 of file XmlChan.h.

88{ setC("XmlPrefix", prefix); }
std::string prefix

◆ show() [1/2]

std::string ast::Object::show ( bool showComments = true) const
inherited

Return a textual description the object as a string.

Parameters
[in]showCommentsShow comments?

Definition at line 165 of file Object.cc.

165 {
167 show(os, showComments);
168 return os.str();
169}

◆ show() [2/2]

void ast::Object::show ( std::ostream & os,
bool showComments = true ) const
inherited

Print a textual description the object to an ostream.

Parameters
[in,out]osThe stream to which to write the string representation.
[in]showCommentsShow comments?

Definition at line 158 of file Object.cc.

158 {
159 Stream stream(nullptr, &os);
160 Channel ch(stream, showComments ? "" : "Comment=0");
161 ch.write(*this);
162 assertOK();
163}

◆ test()

bool ast::Object::test ( std::string const & attrib) const
inlineinherited

Has this attribute been explicitly set (and not subsequently cleared)?

Warning
Unlike the underlying astTest function, throws an exception if an error results

Notes

  • Attribute names are not case sensitive and may be surrounded by white space.
  • As you might expect, the returned value for a read-only attribute is always false.
Exceptions
std::runtime_errorif an error results.

Definition at line 250 of file Object.h.

250 {
251 bool res = astTest(getRawPtr(), attrib.c_str());
252 assertOK();
253 return res;
254 }

◆ unlock()

void ast::Object::unlock ( bool report = false)
inlineinherited

Unlock this object previously locked using lock, so that other threads can use this object.

See lock for further details.

Parameters
[in]reportIf true, an error will be reported if the supplied Object, or any Object contained within the supplied Object, is not currently locked by the running thread. If false, such Objects will be left unchanged, and no error will be reported.

Notes

  • This function attempts to execute even if AST's global error status is set, but no further error report will be made if it subsequently fails under these circumstances.
  • All unlocked Objects are excluded from AST context handling until they are re-locked using astLock.
  • This function returns without action if the Object is not currently locked by any thread. If it is locked by the running thread, it is unlocked. If it is locked by another thread, an error will be reported if "error" is non-zero.
  • This function returns without action if the AST library has been built without POSIX thread support (i.e. the "-with-pthreads" option was not specified when running the "configure" script).

Definition at line 280 of file Object.h.

280 {
281 astUnlock(getRawPtr(), static_cast<int>(report));
282 assertOK();
283 }

◆ warnings()

KeyMap ast::Channel::warnings ( ) const
inherited

Return a KeyMap holding the text of any warnings issued as a result of the previous invocation of read or write.

If no warnings were issued, an empty KeyMap will be returned. Such warnings are non-fatal and will not prevent the read or write operation succeeding. However, the converted object may not be identical to the original object in all respects. Differences which would usually be deemed as insignificant in most usual cases will generate a warning, whereas more significant differences will generate an error.

The " Strict" attribute allows this warning facility to be switched off, so that a fatal error is always reported for any conversion error.

Definition at line 67 of file Channel.cc.

67 {
68 AstKeyMap *rawKeyMap =
69 reinterpret_cast<AstKeyMap *>(astWarnings(reinterpret_cast<AstChannel const *>(getRawPtr())));
70 assertOK();
71 return rawKeyMap ? KeyMap(rawKeyMap) : KeyMap();
72}

◆ write()

int ast::Channel::write ( Object const & object)
inherited

Write an object to a channel.

Definition at line 61 of file Channel.cc.

61 {
62 int ret = astWrite(getRawPtr(), object.getRawPtr());
63 assertOK();
64 return ret;
65}

The documentation for this class was generated from the following file: