std::string FunctionArguments::getUtf8String( const char *name, const std::string &default_value )
{
    if( hasArg( name ) )
    {
        return getUtf8String( name );
    }
    else
    {
        return default_value;
    }
}
void toUi(const AdEntry& entry, Ui::ShowAd* ui)
{
  ui->name->setText(getUtf8String(entry.person.name));
  ui->contacts->setPlainText(getUtf8String(entry.person.contacts));

  ui->country->setText(getUtf8String(entry.location.country));
  ui->state->setText(getUtf8String(entry.location.state));
  ui->town->setText(getUtf8String(entry.location.city));
  ui->address->setText(getUtf8String(entry.location.street_address));
  ui->zipcode->setText(getUtf8String(entry.location.postal_code));

  ui->category->setText(getUtf8String(entry.category.level_1));
  ui->subcategory->setText(getUtf8String(entry.category.level_2));

  ui->title->setText(getUtf8String(entry.ad.title));
  ui->description->setPlainText(getUtf8String(entry.ad.description));
  {
    std::string stags;
    BOOST_FOREACH (const std::string& item, entry.ad.tags)
    {
      if (!stags.empty())
      {
        stags += ", ";
      }
      stags += item;
    }
    ui->tags->setText(getUtf8String(stags));
  }
  ui->price->setText(getUtf8String(entry.ad.price));
  {
    BOOST_FOREACH(const std::string& item, entry.ad.images)
    {
      ui->images->insertItem(ui->images->count(), getUtf8String(item));
    }
  }
  {
    BOOST_FOREACH(const std::string& item, entry.ad.videos)
    {
      ui->videos->insertItem(ui->videos->count(), getUtf8String(item));
    }
  }
}