#include "Util.h"
#include <new>
#include "AddPathsCommand.h"
#include "AddStylesCommand.h"
#include "Container.h"
#include "Style.h"
#include "VectorPath.h"
using std::nothrow;
void
new_style(rgb_color color, Container<Style>* container,
Style** style, AddStylesCommand** command)
{
*style = new (nothrow) Style(color);
if (*style) {
Style* styles[1];
styles[0] = *style;
*command = new (nothrow) AddStylesCommand(
container, styles, 1,
container->CountItems());
if (*command == NULL) {
delete *style;
*style = NULL;
}
} else {
*command = NULL;
}
}
void
new_path(Container<VectorPath>* container, VectorPath** path,
AddPathsCommand** command, VectorPath* other)
{
if (other)
*path = new (nothrow) VectorPath(*other);
else
*path = new (nothrow) VectorPath();
if (*path) {
VectorPath* paths[1];
paths[0] = *path;
int32 insertIndex = other ? container->IndexOf(other) + 1
: container->CountItems();
*command = new (nothrow) AddPathsCommand(
container, paths, 1, true, insertIndex);
if (*command == NULL) {
delete *path;
*path = NULL;
}
} else {
*command = NULL;
}
}