Skip to content

Commit

Permalink
* C++11 conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
RangelReale committed Jul 24, 2015
1 parent 5168cf9 commit 26b6301
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 192 deletions.
10 changes: 5 additions & 5 deletions src/BImage_FreeImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ ButcherImage *ButcherImage_FreeImage::SubImage(const wxRect &r)
{
try
{
auto_ptr<wxFreeImage> si(new wxFreeImage());
std::unique_ptr<wxFreeImage> si(new wxFreeImage());
image_->Copy(*si, r);
return new ButcherImage_FreeImage(si.release());
} catch (wxFreeImageException &e) {
Expand All @@ -190,7 +190,7 @@ wxFreeImage *ButcherImage_FreeImage::ImageFormatPrepare(format_t format, int fla
{
if (image_->GetBPP() > 8 || (tcolors && tcolors->size()>0))
{
auto_ptr<wxFreeImage> img(new wxFreeImage(*image_));
std::unique_ptr<wxFreeImage> img(new wxFreeImage(*image_));
if (image_->GetBPP() > 8)
{
// must be 24 bits do quantize
Expand All @@ -214,7 +214,7 @@ wxFreeImage *ButcherImage_FreeImage::ImageFormatPrepare(format_t format, int fla
// convert to 24 bits
if (image_->NeedConvert(wxFreeImage::CV_24BITS))
{
auto_ptr<wxFreeImage> img(new wxFreeImage(*image_));
std::unique_ptr<wxFreeImage> img(new wxFreeImage(*image_));
img->Convert(wxFreeImage::CV_24BITS);
return img.release();
}
Expand All @@ -231,7 +231,7 @@ wxFreeImage *ButcherImage_FreeImage::ImageFormatPrepare(format_t format, int fla

if (image_->NeedConvert(cv) || (tcolors && tcolors->size()>0))
{
auto_ptr<wxFreeImage> img(new wxFreeImage(*image_));
std::unique_ptr<wxFreeImage> img(new wxFreeImage(*image_));
// convert
if (image_->NeedConvert(cv))
{
Expand Down Expand Up @@ -375,7 +375,7 @@ void ButcherImage_FreeImage::Composite(const wxBitmap &bitmap)
d.rgbBlue=255;

wxImage img(bitmap.ConvertToImage());
auto_ptr<wxFreeImage> cmp(new wxFreeImage(img));
std::unique_ptr<wxFreeImage> cmp(new wxFreeImage(img));
cmp->Convert(wxFreeImage::CV_32BITS);
cmp->ApplyColorMapping(&s, &d, 1, false);

Expand Down
50 changes: 25 additions & 25 deletions src/BList.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include <map>
#include <deque>
#include <set>
#include <memory>
#include <iterator>
#include <cppcomp/linked_ptr.h>
#include <wx/wx.h>
#include "BExcept.h"

Expand Down Expand Up @@ -66,7 +66,7 @@ class ButcherList {
typedef ButcherListAutoUpdate<T> autoupdate_t;

private:
typedef map< BLID_t, linked_ptr<T> > ButcherListList;
typedef map< BLID_t, std::shared_ptr<T> > ButcherListList;
public:
//template <class T>
class iterator : public std::iterator<std::forward_iterator_tag, T>
Expand Down Expand Up @@ -136,7 +136,7 @@ class ButcherList {
protected:
bool op_delete(BLID_t id) {
if (can_delete(id, &*list_[id])) {
linked_ptr<T> d=list_[id];
std::shared_ptr<T> d=list_[id];
do_deleting(id, &*d);

list_.erase(id);
Expand Down Expand Up @@ -176,12 +176,12 @@ class ButcherList {
virtual void do_clear() {}

unsigned long op_add(T* item, BLID_t id = 0) {
linked_ptr<T> newitem(item);
std::shared_ptr<T> newitem(item);
return op_add(newitem, id);
/*
if (id==0) id=++maxid_;
else if (id>maxid_) maxid_=id;
list_[id]=linked_ptr<T>(item);
list_[id]=std::shared_ptr<T>(item);
item->SetBLId(id);
idlist_.insert(id);
internal_modified(id);
Expand All @@ -195,7 +195,7 @@ class ButcherList {
if (orig == dest) return;

typename ButcherListList::iterator i=list_.find(dest);
linked_ptr<T> save(NULL);
std::shared_ptr<T> save(NULL);
if (i!=list_.end())
save=i->second;
list_[dest]=list_[orig];
Expand All @@ -213,7 +213,7 @@ class ButcherList {
list_.erase(orig);
}
private:
unsigned long op_add(linked_ptr<T> &item, BLID_t id = 0) {
unsigned long op_add(std::shared_ptr<T> &item, BLID_t id = 0) {
if (id==0) id=++maxid_;
else if (id>maxid_) maxid_=id;
list_[id]=item;
Expand Down Expand Up @@ -339,7 +339,7 @@ class ButcherList_Fixed {
protected:
bool op_delete(BLID_t id) {
if (Exists(id) && can_delete(id, Get(id))) {
linked_ptr<T> d=*fixedp_get(id);
std::shared_ptr<T> d=*fixedp_get(id);
do_deleting(id, &*d);

fixed_delete(id);
Expand Down Expand Up @@ -404,9 +404,9 @@ class ButcherList_Fixed {
if (orig == dest) return;

// add previous item at end
linked_ptr<T> save(NULL);
std::shared_ptr<T> save(NULL);
if (Get(dest)) {
save=linked_ptr<T>(Get(dest));
save=std::shared_ptr<T>(Get(dest));
op_delete(dest);
}
op_add(Get(orig), dest);
Expand All @@ -424,8 +424,8 @@ class ButcherList_Fixed {
}

virtual void fixed_setblid(T* item, BLID_t id) = 0;
virtual T* fixed_get(BLID_t id) { linked_ptr<T> *f=fixedp_get(id); if (f) return f->get(); return NULL; }
virtual linked_ptr<T> *fixedp_get(BLID_t id) = 0;
virtual T* fixed_get(BLID_t id) { std::shared_ptr<T> *f=fixedp_get(id); if (f) return f->get(); return NULL; }
virtual std::shared_ptr<T> *fixedp_get(BLID_t id) = 0;
virtual unsigned long fixed_count() = 0;
virtual bool fixed_isfull() = 0;
virtual void fixed_delete(BLID_t id) = 0;
Expand Down Expand Up @@ -462,7 +462,7 @@ class ButcherList_1 : public ButcherList_Fixed<T> {
virtual void fixed_setblid(T* item, BLID_t id) {
item->SetBLId(id);
};
virtual linked_ptr<T> *fixedp_get(BLID_t id) {
virtual std::shared_ptr<T> *fixedp_get(BLID_t id) {
if (item1_.get()!=NULL && item1id_==id) return &item1_;
return NULL;
}
Expand All @@ -475,17 +475,17 @@ class ButcherList_1 : public ButcherList_Fixed<T> {
return fixed_count()==1;
}
virtual void fixed_delete(BLID_t id) {
if (id==item1id_) { item1_=linked_ptr<T>(NULL); item1id_=0; }
if (id==item1id_) { item1_=std::shared_ptr<T>(NULL); item1id_=0; }
}
virtual void fixed_clear() {
if (item1_.get()) {
item1_=linked_ptr<T>(NULL);
item1_=std::shared_ptr<T>(NULL);
item1id_=0;
}
}
virtual void fixed_add(T* item, BLID_t id) {
if (item1_.get()==NULL) {
item1_=linked_ptr<T>(item);
item1_=std::shared_ptr<T>(item);
item1id_=id;
} else
throw ButcherException(_("List is full"));
Expand All @@ -495,7 +495,7 @@ class ButcherList_1 : public ButcherList_Fixed<T> {
}
private:
BLID_t item1id_;
linked_ptr<T> item1_;
std::shared_ptr<T> item1_;
};

/**
Expand All @@ -521,7 +521,7 @@ class ButcherList_2 : public ButcherList_Fixed<T> {
virtual void fixed_setblid(T* item, BLID_t id) {
item->SetBLId(id);
};
virtual linked_ptr<T> *fixedp_get(BLID_t id) {
virtual std::shared_ptr<T> *fixedp_get(BLID_t id) {
if (item1_.get()!=NULL && item1id_==id) return &item1_;
if (item2_.get()!=NULL && item2id_==id) return &item2_;
return NULL;
Expand All @@ -536,25 +536,25 @@ class ButcherList_2 : public ButcherList_Fixed<T> {
return fixed_count()==2;
}
virtual void fixed_delete(BLID_t id) {
if (id==item1id_) { item1_=linked_ptr<T>(NULL); item1id_=0; }
if (id==item2id_) { item2_=linked_ptr<T>(NULL); item2id_=0; }
if (id==item1id_) { item1_=std::shared_ptr<T>(NULL); item1id_=0; }
if (id==item2id_) { item2_=std::shared_ptr<T>(NULL); item2id_=0; }
}
virtual void fixed_clear() {
if (item1_.get()) {
item1_=linked_ptr<T>(NULL);
item1_=std::shared_ptr<T>(NULL);
item1id_=0;
}
if (item2_.get()) {
item2_=linked_ptr<T>(NULL);
item2_=std::shared_ptr<T>(NULL);
item2id_=0;
}
}
virtual void fixed_add(T* item, BLID_t id) {
if (item1_.get()==NULL) {
item1_=linked_ptr<T>(item);
item1_=std::shared_ptr<T>(item);
item1id_=id;
} else if (item2_.get()==NULL) {
item2_=linked_ptr<T>(item);
item2_=std::shared_ptr<T>(item);
item2id_=id;
} else
throw ButcherException(_("List is full"));
Expand All @@ -565,7 +565,7 @@ class ButcherList_2 : public ButcherList_Fixed<T> {
}
private:
BLID_t item1id_, item2id_;
linked_ptr<T> item1_, item2_;
std::shared_ptr<T> item1_, item2_;
};
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/BProc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void ButcherProjectProc_AreaMenu::ProcessAreaMenu(int menuid)
if (d.ShowModal()==wxID_OK)
{
wxFileName fn(d.GetPath());
auto_ptr<ButcherImage> aimg(view_->GetFile()->GetSubImage(area->GetGlobalRect()));
std::unique_ptr<ButcherImage> aimg(view_->GetFile()->GetSubImage(area->GetGlobalRect()));
aimg->Save(ButcherImage::GetExtFormat(fn.GetExt()), d.GetPath(), 0);
}

Expand All @@ -349,7 +349,7 @@ void ButcherProjectProc_AreaMenu::ProcessAreaMenu(int menuid)
wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
if (d.ShowModal()==wxID_OK)
{
auto_ptr<ButcherImage> img(view_->CreateAreaImage(area));
std::unique_ptr<ButcherImage> img(view_->CreateAreaImage(area));
if (img.get())
img->Save(area->Configs().Get(view_->GetBLId())->ImageInfo().GetSaveParams(), d.GetPath());
else
Expand Down
14 changes: 7 additions & 7 deletions src/ButcherMetadataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void ButcherMetadataData::Add(ButcherMetadataDataItem *item)
{
if (item->GetMetadataData() != this)
throw ButcherException(_("This item is not for this data"));
data_[item->GetMetadataID()]=linked_ptr<ButcherMetadataDataItem>(item);
data_[item->GetMetadataID()]=std::shared_ptr<ButcherMetadataDataItem>(item);
}

ButcherMetadataData *ButcherMetadataData::MultiAdd(ButcherMetadataDataItem *item)
Expand Down Expand Up @@ -289,7 +289,7 @@ ButcherMetadataData &ButcherMetadataDataList::Get(int index)
ButcherMetadataData *ButcherMetadataDataList::Add()
{
ButcherMetadataData *ret=new ButcherMetadataData(this);
datalist_.push_back(linked_ptr<ButcherMetadataData>(ret));
datalist_.push_back(std::shared_ptr<ButcherMetadataData>(ret));
return ret;
}

Expand Down Expand Up @@ -323,7 +323,7 @@ void ButcherMetadataStorage::Add(ButcherMetadataID_t id)
{
if (list_.find(id)==list_.end())
listorder_.push_back(id);
list_[id]=linked_ptr<ButcherMetadataDataList>(new ButcherMetadataDataList(this, id));
list_[id]=std::shared_ptr<ButcherMetadataDataList>(new ButcherMetadataDataList(this, id));
}

bool ButcherMetadataStorage::Exists(ButcherMetadataID_t id)
Expand Down Expand Up @@ -415,7 +415,7 @@ bool ButcherMetadataFile::ReadMetadata(wxFile &file, ButcherMetadataStorage *sto
butchermetadata_dataitemheader_t dataitemheader;
ButcherMetadataDataItem *newitem;
ButcherMetadataData *curmd=NULL;
//auto_ptr<char> itemdata;
//std::unique_ptr<char> itemdata;
size_t n;
bool started=false, readitemend;

Expand Down Expand Up @@ -488,11 +488,11 @@ bool ButcherMetadataFile::ReadMetadata(wxFile &file, ButcherMetadataStorage *sto
{
if (newitem->ReadData())
{
//itemdata=auto_ptr<char>(new char[dataitemheader.datasize]);
//itemdata=std::unique_ptr<char>(new char[dataitemheader.datasize]);
#ifndef _MSC_VER
char itemdata[dataitemheader.datasize];
#else
auto_ptr<char> itemdata_auto(new char[dataitemheader.datasize]);
std::unique_ptr<char> itemdata_auto(new char[dataitemheader.datasize]);
char *itemdata=itemdata_auto.get();
#endif
n=file.Read(&*itemdata, dataitemheader.datasize);
Expand Down Expand Up @@ -601,7 +601,7 @@ bool ButcherMetadataFile::WriteMetadata(wxFile &file, ButcherMetadataStorage *st
ButcherMetadataDataList *curlist;
ButcherMetadataData *curdata;
ButcherMetadataData::data_t::const_iterator dataiterator;
auto_ptr<ButcherMetadataBinary> itembin;
std::unique_ptr<ButcherMetadataBinary> itembin;

char buf[BMD_BUF_TEMP_SIZE];
size_t nRead, nTotal;
Expand Down
9 changes: 4 additions & 5 deletions src/ButcherMetadataFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

#include <deque>
#include <map>
#include <memory>
#include <wx/wx.h>
#include <wx/file.h>
#include <cppcomp/linked_ptr.h>

#include <wx/sstream.h>
#include <wx/mstream.h>

Expand Down Expand Up @@ -298,7 +297,7 @@ class ButcherMetadataData
ButcherMetadataDataItem &Get(ButcherMetadataID_t id);


typedef map< ButcherMetadataID_t, linked_ptr< ButcherMetadataDataItem > > data_t;
typedef map< ButcherMetadataID_t, std::shared_ptr< ButcherMetadataDataItem > > data_t;

const data_t &GetData() { return data_; }

Expand All @@ -320,7 +319,7 @@ class ButcherMetadataData
class ButcherMetadataDataList
{
public:
typedef deque< linked_ptr< ButcherMetadataData > > datalist_t;
typedef deque< std::shared_ptr< ButcherMetadataData > > datalist_t;

ButcherMetadataDataList(ButcherMetadataStorage *storage, ButcherMetadataID_t metadataid);

Expand Down Expand Up @@ -363,7 +362,7 @@ class ButcherMetadataStorage
protected:
friend class ButcherMetadataFile;
private:
typedef map< ButcherMetadataID_t, linked_ptr< ButcherMetadataDataList > > list_t;
typedef map< ButcherMetadataID_t, std::shared_ptr< ButcherMetadataDataList > > list_t;
list_t list_;
listorder_t listorder_;
};
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/DialogFileLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ void HTMLButcherFileLinkDialog::ExpandLink(const ButcherProjectFileLink &link)
{
wxTreeCtrl *linksctrl=(wxTreeCtrl*)FindWindow(ID_LINKS);

auto_ptr<FileLinkTreeItemData> finddata(NULL);
std::unique_ptr<FileLinkTreeItemData> finddata;
wxTreeItemId cid;

switch (link.GetLinkType())
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/DialogMaskAreaFileAlternate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void HTMLButcherMaskAreaFileAlternateDialog::Load(ButcherProjectView *view, Butc

for (int i=0; i<BUTCHERCONST_VIEW_MAXALTERNATE; i++)
{
altimageinfo_.push_back(linked_ptr<ButcherProjectAreaImageInfo>(new ButcherProjectAreaImageInfo(loadconfig->AlternateImageInfo(i))));
altimageinfo_.push_back(std::shared_ptr<ButcherProjectAreaImageInfo>(new ButcherProjectAreaImageInfo(loadconfig->AlternateImageInfo(i))));
altimageinfo_[i]->ResetAreaConfig();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/DialogMaskAreaFileAlternate.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class HTMLButcherMaskAreaFileAlternateDialog: public ButcherControl_Dialog
ButcherProjectArea *area_;
ButcherProjectAreaConfig *config_;

deque< linked_ptr<ButcherProjectAreaImageInfo> > altimageinfo_;
deque< std::shared_ptr<ButcherProjectAreaImageInfo> > altimageinfo_;
};

#endif //__DIALOGMASKAERAFILEALTERNATE_H__
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/DialogMaskAreaImageFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ bool HTMLButcherMaskAreaImageFormatDialog::TransferDataToWindow()
p1formatctrl->SetSelection(p1formatctrl->Append(_("- DEFAULT -"), static_cast<wxClientData *>(new ButcherListIdClientData(0))));
p2formatctrl->SetSelection(p2formatctrl->Append(_("- DEFAULT -"), static_cast<wxClientData *>(new ButcherListIdClientData(0))));

auto_ptr<ButcherImage> origimage(file_->GetImage()->SubImage(area_->GetGlobalRect())), fmtimage(NULL);
std::unique_ptr<ButcherImage> origimage(file_->GetImage()->SubImage(area_->GetGlobalRect())), fmtimage;

ButcherProjectBaseAutoProgress prog(GetProject(), _("Calculating file sizes, please wait..."));

Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/WizNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ bool HTMLButcherNewViewFileWizardPage::TransferDataFromWindow()
return false;
}

auto_ptr<ButcherImage> limg(ButcherImageFactory::Load(fn.GetFullPath()));
std::unique_ptr<ButcherImage> limg(ButcherImageFactory::Load(fn.GetFullPath()));
if (!limg.get())
{
wxMessageBox(_("Unknown image file format."), _("Error"),
Expand Down
Loading

0 comments on commit 26b6301

Please sign in to comment.