コード例 #1
0
ファイル: Print.hpp プロジェクト: DaemonSnake/MetaProgramming
void print()
{
    int status = -4;
    const char *name = typeid(T).name();
    std::string true_name = abi::__cxa_demangle(name, 0, 0, &status);
    std::string class_name = find_class_name(true_name);
    std::string namespe = [&]() -> std::string {
        std::size_t i = class_name.rfind("::");
        if (i != std::string::npos)
            return class_name.substr(0, i);
        else
            return "";
    }();
   if (!namespe.empty()) {
        std::string::size_type n = 0;
        while ( ( n = true_name.find( namespe, n ) ) != std::string::npos )
        {
            true_name.replace( n, namespe.size(), "" );
            n += 0;
        }
    }
    std::cout <<  true_name;
    if (!namespe.empty())
        std::cout << " (:: ==> " + namespe + ")";
    std::cout << std::endl;
}
コード例 #2
0
ファイル: st-widget.c プロジェクト: MarkieMark/gnome-shell
/**
 * st_widget_has_style_pseudo_class:
 * @actor: a #StWidget
 * @pseudo_class: a pseudo class string
 *
 * Tests if @actor's pseudo class list includes @pseudo_class.
 *
 * Returns: whether or not @actor's pseudo class list includes
 * @pseudo_class.
 */
gboolean
st_widget_has_style_pseudo_class (StWidget    *actor,
                                  const gchar *pseudo_class)
{
  g_return_val_if_fail (ST_IS_WIDGET (actor), FALSE);

  return find_class_name (actor->priv->pseudo_class, pseudo_class) != NULL;
}
コード例 #3
0
ファイル: st-widget.c プロジェクト: MarkieMark/gnome-shell
static gboolean
add_class_name (gchar       **class_list,
                const gchar  *class_name)
{
  gchar *new_class_list;

  if (*class_list)
    {
      if (find_class_name (*class_list, class_name))
        return FALSE;

      new_class_list = g_strdup_printf ("%s %s", *class_list, class_name);
      g_free (*class_list);
      *class_list = new_class_list;
    }
  else
    *class_list = g_strdup (class_name);

  return TRUE;
}
コード例 #4
0
ファイル: st-widget.c プロジェクト: MarkieMark/gnome-shell
static gboolean
remove_class_name (gchar       **class_list,
                   const gchar  *class_name)
{
  const gchar *match, *end;
  gchar *new_class_list;

  if (!*class_list)
    return FALSE;

  if (strcmp (*class_list, class_name) == 0)
    {
      g_free (*class_list);
      *class_list = NULL;
      return TRUE;
    }

  match = find_class_name (*class_list, class_name);
  if (!match)
    return FALSE;
  end = match + strlen (class_name);

  /* Adjust either match or end to include a space as well.
   * (One or the other must be possible at this point.)
   */
  if (match != *class_list)
    match--;
  else
    end++;

  new_class_list = g_strdup_printf ("%.*s%s", (int)(match - *class_list),
                                    *class_list, end);
  g_free (*class_list);
  *class_list = new_class_list;

  return TRUE;
}