15#include <QVarLengthArray>
20#include <nlohmann/json.hpp>
125 void setUnits(QString value, QString units);
138 bool isNull(
const int index = 0)
const;
142 friend std::ostream &
operator<<(std::ostream &os,
146 operator double()
const {
150 operator int()
const {
151 return toInt(
operator[](0));
158 operator QString()
const;
162 QString
unit(
const int index = 0)
const;
173 QString
comment(
const int index)
const;
194 return !(*
this == key);
197 bool isEquivalent(QString string1,
int index = 0)
const;
233 const QString &string2);
236 static QString
readLine(std::istream &is,
bool insideComment);
239 std::vector< QString > &keywordComments,
240 QString &keywordName,
241 std::vector< std::pair<QString, QString> >
244 static QString readValue(QString &keyword,
bool "eProblem);
245 static QString readValue(QString &keyword,
bool "eProblem,
246 const std::vector< std::pair<char, char> > &
255 QString
reform(
const QString &value)
const;
256 QString
toPvl(
const QString &value)
const;
257 QString
toIPvl(
const QString &value)
const;
259 const QString &textToWrite,
A single keyword-value pair.
PvlKeyword()
Constructs a blank PvlKeyword object.
std::vector< QString > * m_comments
The comments for the keyword.
QVarLengthArray< QString, 1 > m_values
The values in the keyword.
void setIndent(int indent)
Sets the indent level when outputted(for formatting)
const QString & operator[](int index) const
Gets value for this object at specified index.
void setName(QString name)
Sets the keyword name.
friend std::istream & operator>>(std::istream &is, PvlKeyword &result)
Read in a keyword.
void setJsonValue(nlohmann::json jsonobj, QString unit="")
Sets new value from Json.
QString toIPvl(const QString &value) const
Converts a value to iPVL format.
int width() const
Returns the current set longest keyword name.
QString name() const
Returns the keyword name.
int size() const
Returns the number of values stored in this keyword.
PvlKeyword & operator+=(QString value)
Adds a value.
std::vector< QString > * m_units
The units for the values.
bool isNull(const int index=0) const
Decides whether a value is null or not at a given index.
char * m_name
The keyword's name... This is a c-string for memory efficiency.
static bool readCleanKeyword(QString keyword, std::vector< QString > &keywordComments, QString &keywordName, std::vector< std::pair< QString, QString > > &keywordValues)
This reads a keyword compressed back to 1 line of data (excluding comments, which are included on sep...
QString unit(const int index=0) const
Returns the units of measurement of the element of the array of values for the object at the specifie...
~PvlKeyword()
Destructs a PvlKeyword object.
void setFormat(PvlFormat *formatter)
Set the PvlFormatter used to format the keyword name and value(s)
friend std::ostream & operator<<(std::ostream &os, const PvlKeyword &keyword)
Write out the keyword.
int comments() const
Returns the number of lines of comments associated with this keyword.
QString comment(const int index) const
Return a comment at the specified index.
PvlFormat * m_formatter
Formatter object.
bool operator==(const PvlKeyword &key) const
Returns true of the keyword names match.
int indent() const
Returns the current indent level.
QString reform(const QString &value) const
Checks if the value needs to be converted to PVL or iPVL and returns it in the correct format.
void setUnits(QString units)
Sets the unit of measure for all current values if any exist.
void setWidth(int width)
The width of the longest keyword name (for formatting)
static bool stringEqual(const QString &string1, const QString &string2)
Checks to see if two QStrings are equal.
bool operator!=(const PvlKeyword &key) const
Returns true of the keyword names do not match.
bool isNamed(QString name) const
Determines whether two PvlKeywords have the same name or not.
PvlFormat * format()
Get the current PvlFormat or create one.
void addCommentWrapped(QString comment)
Automatically wraps and adds long comments to the PvlKeyword.
QString toPvl(const QString &value) const
Converts a value to PVL format.
void addJsonValue(nlohmann::json jsonobj, QString unit="")
Adds a value with units.
PvlKeyword & operator=(QString value)
Sets new values.
void writeSpaces(std::ostream &, int) const
This writes numSpaces spaces to the ostream.
std::ostream & writeWithWrap(std::ostream &os, const QString &textToWrite, int startColumn, PvlFormat &format) const
Wraps output so that length doesn't exceed the character limit.
void setValue(QString value, QString unit="")
Sets new values.
void addComment(QString comment)
Add a comment to the PvlKeyword.
int m_width
The width of the longest keyword.
bool isEquivalent(QString string1, int index=0) const
Checks to see if a value with a specified index is equivalent to another QString.
void clearComment()
Clears the current comments.
void addComments(const std::vector< QString > &comments)
This method adds multiple comments at once by calling AddComments on each element in the vector.
static QString readLine(std::istream &is, bool insideComment)
This method reads one line of data from the input stream.
int m_indent
The number of indentations to make.
void clear()
Clears all values and units for this PvlKeyword object.
void validateKeyword(PvlKeyword &pvlKwrd, QString psValueType="", PvlKeyword *pvlKwrdRange=NULL)
Validate Keyword for type and required values.
void init()
Clears all PvlKeyword data.
void addValue(QString value, QString unit="")
Adds a value with units.
Parse and return elements of a Pvl sequence.
This is free and unencumbered software released into the public domain.
int toInt(const QString &string)
Global function to convert from a string to an integer.
BigInt toBigInt(const QString &string)
Global function to convert from a string to a "big" integer.
long long int BigInt
Big int.
double toDouble(const QString &string)
Global function to convert from a string to a double.