* Ownership of the objects returned by this function is passed to the
* caller of this function.
*/
- virtual PatternBase *clone () const = 0;
+ virtual std::unique_ptr<PatternBase> clone () const = 0;
/**
* Determine an estimate for the memory consumption (in bytes) of this
/**
* Return pointer to the correct derived class based on description.
*/
- PatternBase *pattern_factory (const std::string &description);
+ std::unique_ptr<PatternBase> pattern_factory (const std::string &description);
/**
* Test for the string being an integer. If bounds are given to the
* heap. Ownership of that object is transferred to the caller of this
* function.
*/
- virtual PatternBase *clone () const;
+ virtual std::unique_ptr<PatternBase> clone () const;
/**
* Creates new object if the start of description matches
* description_init. Ownership of that object is transferred to the
* caller of this function.
*/
- static Integer *create (const std::string &description);
+ static std::unique_ptr<Integer> create (const std::string &description);
private:
/**
* heap. Ownership of that object is transferred to the caller of this
* function.
*/
- virtual PatternBase *clone () const;
+ virtual std::unique_ptr<PatternBase> clone () const;
/**
* Creates a new object on the heap using @p new if the given
* of the returned object is transferred to the caller of this function,
* which should be freed using @p delete.
*/
- static Double *create (const std::string &description);
+ static std::unique_ptr<Double> create(const std::string &description);
private:
/**
* heap. Ownership of that object is transferred to the caller of this
* function.
*/
- virtual PatternBase *clone () const;
+ virtual std::unique_ptr<PatternBase> clone () const;
/**
* Determine an estimate for the memory consumption (in bytes) of this
* description_init. Ownership of that object is transferred to the
* caller of this function.
*/
- static Selection *create (const std::string &description);
+ static std::unique_ptr<Selection> create (const std::string &description);
private:
/**
* heap. Ownership of that object is transferred to the caller of this
* function.
*/
- virtual PatternBase *clone () const;
+ virtual std::unique_ptr<PatternBase> clone () const;
/**
* Creates new object if the start of description matches
* description_init. Ownership of that object is transferred to the
* caller of this function.
*/
- static List *create (const std::string &description);
+ static std::unique_ptr<List> create (const std::string &description);
/**
* Determine an estimate for the memory consumption (in bytes) of this
* heap. Ownership of that object is transferred to the caller of this
* function.
*/
- virtual PatternBase *clone () const;
+ virtual std::unique_ptr<PatternBase> clone () const;
/**
* Creates new object if the start of description matches
* description_init. Ownership of that object is transferred to the
* caller of this function.
*/
- static Map *create (const std::string &description);
+ static std::unique_ptr<Map> create (const std::string &description);
/**
* Determine an estimate for the memory consumption (in bytes) of this
* heap. Ownership of that object is transferred to the caller of this
* function.
*/
- virtual PatternBase *clone () const;
+ virtual std::unique_ptr<PatternBase> clone () const;
/**
* Creates new object if the start of description matches
* description_init. Ownership of that object is transferred to the
* caller of this function.
*/
- static MultipleSelection *create (const std::string &description);
+ static std::unique_ptr<MultipleSelection> create (const std::string &description);
/**
* Determine an estimate for the memory consumption (in bytes) of this
* heap. Ownership of that object is transferred to the caller of this
* function.
*/
- virtual PatternBase *clone () const;
+ virtual std::unique_ptr<PatternBase> clone () const;
/**
* Creates new object if the start of description matches
* description_init. Ownership of that object is transferred to the
* caller of this function.
*/
- static Bool *create (const std::string &description);
+ static std::unique_ptr<Bool> create(const std::string &description);
private:
/**
* heap. Ownership of that object is transferred to the caller of this
* function.
*/
- virtual PatternBase *clone () const;
+ virtual std::unique_ptr<PatternBase> clone () const;
/**
* Creates new object if the start of description matches
* description_init. Ownership of that object is transferred to the
* caller of this function.
*/
- static Anything *create (const std::string &description);
+ static std::unique_ptr<Anything> create(const std::string &description);
private:
/**
* heap. Ownership of that object is transferred to the caller of this
* function.
*/
- virtual PatternBase *clone () const;
+ virtual std::unique_ptr<PatternBase> clone () const;
/**
* file type flag
* description_init. Ownership of that object is transferred to the
* caller of this function.
*/
- static FileName *create (const std::string &description);
+ static std::unique_ptr<FileName> create (const std::string &description);
private:
/**
* heap. Ownership of that object is transferred to the caller of this
* function.
*/
- virtual PatternBase *clone () const;
+ virtual std::unique_ptr<PatternBase> clone () const;
/**
* Creates new object if the start of description matches
* description_init. Ownership of that object is transferred to the
* caller of this function.
*/
- static DirectoryName *create (const std::string &description);
+ static std::unique_ptr<DirectoryName> create(const std::string &description);
private:
/**
- PatternBase *pattern_factory (const std::string &description)
+ std::unique_ptr<PatternBase> pattern_factory(const std::string &description)
{
- PatternBase *p;
+ std::unique_ptr<PatternBase> p;
p = Integer::create(description);
if (p != nullptr)
Assert(false, ExcNotImplemented());
- return nullptr;
+ return p;
}
- PatternBase *
- Integer::clone () const
+ std::unique_ptr<PatternBase> Integer::clone() const
{
- return new Integer(lower_bound, upper_bound);
+ return std::unique_ptr<PatternBase>(new Integer(lower_bound, upper_bound));
}
- Integer *Integer::create (const std::string &description)
+ std::unique_ptr<Integer> Integer::create(const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
{
is.ignore(strlen(description_init) + strlen(" range "));
if (!(is >> lower_bound))
- return new Integer();
+ return std::unique_ptr<Integer>(new Integer());
is.ignore(strlen("..."));
if (!(is >> upper_bound))
- return new Integer();
+ return std::unique_ptr<Integer>(new Integer());
- return new Integer(lower_bound, upper_bound);
+ return std::unique_ptr<Integer>(new Integer(lower_bound, upper_bound));
}
else
- return new Integer();
+ return std::unique_ptr<Integer>(new Integer());
}
else
- return nullptr;
+ return std::unique_ptr<Integer>();
}
}
- PatternBase *
- Double::clone () const
+ std::unique_ptr<PatternBase> Double::clone() const
{
- return new Double(lower_bound, upper_bound);
+ return std::unique_ptr<PatternBase>(new Double(lower_bound, upper_bound));
}
- Double *Double::create (const std::string &description)
+ std::unique_ptr<Double> Double::create (const std::string &description)
{
const std::string description_init_str = description_init;
if (description.compare(0, description_init_str.size(), description_init_str) != 0)
- return nullptr;
+ return std::unique_ptr<Double>();
if (*description.rbegin() != ']')
- return nullptr;
+ return std::unique_ptr<Double>();
std::string temp = description.substr(description_init_str.size());
if (temp == "]")
- return new Double(1.0, -1.0); // return an invalid range
+ return std::unique_ptr<Double>(new Double(1.0, -1.0)); // return an invalid range
if (temp.find("...") != std::string::npos)
temp.replace(temp.find("..."), 3, " ");
{
// parse lower bound and give up if not a double
if (!(is >> lower_bound))
- return nullptr;
+ return std::unique_ptr<Double>();
}
// ignore failure here and assume we got MAX_DOUBLE as upper bound:
if (is.fail())
upper_bound = max_double_value;
- return new Double(lower_bound, upper_bound);
+ return std::unique_ptr<Double>(new Double(lower_bound, upper_bound));
}
- PatternBase *
- Selection::clone () const
+ std::unique_ptr<PatternBase> Selection::clone() const
{
- return new Selection(sequence);
+ return std::unique_ptr<PatternBase>(new Selection(sequence));
}
- Selection *Selection::create (const std::string &description)
+ std::unique_ptr<Selection> Selection::create(const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
{
sequence.erase(0, std::strlen(description_init) + 1);
sequence.erase(sequence.length()-2, 2);
- return new Selection(sequence);
+ return std::unique_ptr<Selection>(new Selection(sequence));
}
else
- return nullptr;
+ return std::unique_ptr<Selection>();
}
- PatternBase *
- List::clone () const
+ std::unique_ptr<PatternBase> List::clone() const
{
- return new List(*pattern, min_elements, max_elements, separator);
+ return std::unique_ptr<PatternBase>(new List(*pattern, min_elements, max_elements, separator));
}
- List *List::create (const std::string &description)
+ std::unique_ptr<List> List::create (const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
{
is.ignore(strlen(" of length "));
if (!(is >> min_elements))
- return new List(*base_pattern);
+ return std::unique_ptr<List>(new List(*base_pattern));
is.ignore(strlen("..."));
if (!(is >> max_elements))
- return new List(*base_pattern, min_elements);
+ return std::unique_ptr<List>(new List(*base_pattern, min_elements));
is.ignore(strlen(" separated by <"));
std::string separator;
else
separator = ",";
- return new List(*base_pattern, min_elements, max_elements, separator);
+ return std::unique_ptr<List>(new List(*base_pattern, min_elements, max_elements, separator));
}
else
- return nullptr;
+ return std::unique_ptr<List>();
}
- PatternBase *
- Map::clone () const
+ std::unique_ptr<PatternBase> Map::clone() const
{
- return new Map(*key_pattern, *value_pattern,
- min_elements, max_elements,
- separator);
+ return std::unique_ptr<PatternBase>(new Map(*key_pattern, *value_pattern,
+ min_elements, max_elements,
+ separator));
}
- Map *Map::create (const std::string &description)
+ std::unique_ptr<Map> Map::create (const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
{
is.ignore(strlen(" of length "));
if (!(is >> min_elements))
- return new Map(*key_pattern, *value_pattern);
+ return std::unique_ptr<Map>(new Map(*key_pattern, *value_pattern));
is.ignore(strlen("..."));
if (!(is >> max_elements))
- return new Map(*key_pattern, *value_pattern, min_elements);
+ return std::unique_ptr<Map>(new Map(*key_pattern, *value_pattern, min_elements));
is.ignore(strlen(" separated by <"));
std::string separator;
else
separator = ",";
- return new Map(*key_pattern, *value_pattern,
- min_elements, max_elements,
- separator);
+ return std::unique_ptr<Map>(new Map(*key_pattern, *value_pattern,
+ min_elements, max_elements,
+ separator));
}
else
- return nullptr;
+ return std::unique_ptr<Map>();
}
- PatternBase *
- MultipleSelection::clone () const
+ std::unique_ptr<PatternBase> MultipleSelection::clone() const
{
- return new MultipleSelection(sequence);
+ return std::unique_ptr<PatternBase>(new MultipleSelection(sequence));
}
- MultipleSelection *MultipleSelection::create (const std::string &description)
+ std::unique_ptr<MultipleSelection> MultipleSelection::create (const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
{
sequence.erase(0, std::strlen(description_init) + 1);
sequence.erase(sequence.length()-2, 2);
- return new MultipleSelection(sequence);
+ return std::unique_ptr<MultipleSelection>(new MultipleSelection(sequence));
}
else
- return nullptr;
+ return std::unique_ptr<MultipleSelection>();
}
- PatternBase *
- Bool::clone () const
+ std::unique_ptr<PatternBase> Bool::clone() const
{
- return new Bool();
+ return std::unique_ptr<PatternBase>(new Bool());
}
- Bool *Bool::create (const std::string &description)
+ std::unique_ptr<Bool> Bool::create (const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
- return new Bool();
+ return std::unique_ptr<Bool>(new Bool());
else
- return nullptr;
+ return std::unique_ptr<Bool>();
}
- PatternBase *
- Anything::clone () const
+ std::unique_ptr<PatternBase> Anything::clone() const
{
- return new Anything();
+ return std::unique_ptr<PatternBase>(new Anything());
}
- Anything *Anything::create (const std::string &description)
+ std::unique_ptr<Anything> Anything::create (const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
- return new Anything();
+ return std::unique_ptr<Anything>(new Anything());
else
- return nullptr;
+ return std::unique_ptr<Anything>();
}
- PatternBase *
- FileName::clone () const
+ std::unique_ptr<PatternBase> FileName::clone() const
{
- return new FileName(file_type);
+ return std::unique_ptr<PatternBase>(new FileName(file_type));
}
- FileName *FileName::create (const std::string &description)
+ std::unique_ptr<FileName> FileName::create (const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
{
else
type = output;
- return new FileName(type);
+ return std::unique_ptr<FileName>(new FileName(type));
}
else
- return nullptr;
+ return std::unique_ptr<FileName>();
}
- PatternBase *
- DirectoryName::clone () const
+ std::unique_ptr<PatternBase> DirectoryName::clone() const
{
- return new DirectoryName();
+ return std::unique_ptr<PatternBase>(new DirectoryName());
}
- DirectoryName *DirectoryName::create (const std::string &description)
+ std::unique_ptr<DirectoryName> DirectoryName::create (const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
- return new DirectoryName();
+ return std::unique_ptr<DirectoryName>(new DirectoryName());
else
- return nullptr;
+ return std::unique_ptr<DirectoryName>();
}
} // end namespace Patterns