Пример #1
0
ASTNode::ASTNode (NodeType nodetype, OSLCompilerImpl *compiler, int op,
                  ASTNode *a, ASTNode *b)
    : m_nodetype(nodetype), m_compiler(compiler),
      m_sourcefile(compiler->filename()),
      m_sourceline(compiler->lineno()), m_op(op), m_is_lvalue(false)
{
    addchild (a);
    addchild (b);
}
Пример #2
0
hud::hud(engine* e,tgaInfo* fonttexture) : object2d::object2d(){
	this->myengine = e;
  this->font=fonttexture;
  this->initfont();
  window* w = new window(this);
  w->setlocation(100,100);
  addchild(w);
  mainmenu* m = new mainmenu(this);
  addchild(m);
}
Пример #3
0
 bool addchild(TreeNode *root, int accum, int sum)
 {       
     int acc = accum  + root->val;
     if(acc==sum && isleaf(root))
         return true;
     if(root->left != NULL){   
         return addchild(root->left, acc, sum);
     }
     
     if(root->right != NULL){   
         return addchild(root->right, acc, sum);
     }
     return false;
     
 }
Пример #4
0
static
void
loadchilds(Page *p, Kidinfo *k)
{
	Runestr rs;
	Kidinfo *t;
	Page *c;

	addrefresh(p, "loading frames...");
	p->kidinfo = k;
	for(t=k->kidinfos; t!=nil; t=t->next){
		c = emalloc(sizeof(Page));
		addchild(p, c);
		if(t->isframeset){
			c->url = urldup(p->url);
			loadchilds(c, t);
		}else{
			c->kidinfo = t;
			/* this check shouldn't be necessary, but... */
			if(t->src){
				rs.r = urlcombine(p->url->act.r, t->src);
				rs.nr = runestrlen(rs.r);
				pageload1(c, urlalloc(&rs, nil, HGet), FALSE);
				closerunestr(&rs);
			}
		}
	}
}
Пример #5
0
    bool hasPathSum(TreeNode *root, int sum) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        if(root==NULL)
            return false; 
        return(addchild(root, 0, sum));

    }
Пример #6
0
Файл: exptree.c Проект: pix/cppp
/* Creates and returns a new subtree, with pos being the index of
 * which child branch to insert the new subtree at.
 */
static struct exptree *addnewchild(struct exptree *t, int pos)
{
    struct exptree *child;

    child = initexptree();
    if (!addchild(t, child, pos)) {
	deallocate(child);
	return NULL;
    }
    return child;
}
Пример #7
0
void processrequest(formfield *fields, int count)
{
  formfield *command;

  command=findfield("command",fields,count);

  if(command==NULL)
    printmessagefromtemplate(WRONGFORMAT_TEMPLATE);
  else if(strcmp(command->data,"addnew")==0)
    addnewuser(fields,count);
  else if(strcmp(command->data,"addchild")==0)
    addchild(fields,count);
  else
    printmessagefromtemplate(WRONGFORMAT_TEMPLATE);
}
Пример #8
0
Object *
search(Object *rt, Object *parent, Reprog *preg) {
    /* Create a `search object', a subtree of rt containing
     * only objects with s in their value of key fields plus
     * their parentage.
     *
     * Algorithm: depth-first traversal of rt.  On the way down,
     * copy rt to nr (new root), on the way back up, delete
     * subtrees without match.
     *
     * returns null when there are no matches in rt's subtree
     */
    Object *o, *nr;
    char *s;
    int i;
    int yes = 0;

    nr = newobject(rt->type, parent);
    nr->orig = rt->orig?rt->orig:rt;
    nr->value = rt->value;
    strncpy(nr->key, rt->key, KEYLEN);

    if((((s = nr->value)) && regexec(preg, s, nil, 0) == 1)
            || (((s = nr->value)) && regexec(preg, s, nil, 0) == 1))
        yes = 1;
    for(i = 0; i < rt->nchildren; i++)
        if((o = search((Object*)rt->children[i], nr, preg))) {
            yes = 1;
            addchild(nr, o, "search");
        }
    if(yes == 0) {
        freeobject(nr, "s");
        return nil;
    }
    return nr;
}
Пример #9
0
NODE *
spec(FILE *fp)
{
	NODE *centry, *last, *pathparent, *cur;
	char *p, *e, *next;
	NODE ginfo, *root;
	char *buf, *tname, *ntname;
	size_t tnamelen, plen;

	root = NULL;
	centry = last = NULL;
	tname = NULL;
	tnamelen = 0;
	memset(&ginfo, 0, sizeof(ginfo));
	for (mtree_lineno = 0;
	    (buf = fparseln(fp, NULL, &mtree_lineno, NULL,
		FPARSELN_UNESCCOMM));
	    free(buf)) {
		/* Skip leading whitespace. */
		for (p = buf; *p && isspace((unsigned char)*p); ++p)
			continue;

		/* If nothing but whitespace, continue. */
		if (!*p)
			continue;

#ifdef DEBUG
		fprintf(stderr, "line %lu: {%s}\n",
		    (u_long)mtree_lineno, p);
#endif
		/* Grab file name, "$", "set", or "unset". */
		next = buf;
		while ((p = strsep(&next, " \t")) != NULL && *p == '\0')
			continue;
		if (p == NULL)
			mtree_err("missing field");

		if (p[0] == '/') {
			if (strcmp(p + 1, "set") == 0)
				set(next, &ginfo);
			else if (strcmp(p + 1, "unset") == 0)
				unset(next, &ginfo);
			else
				mtree_err("invalid specification `%s'", p);
			continue;
		}

		if (strcmp(p, "..") == 0) {
			/* Don't go up, if haven't gone down. */
			if (root == NULL)
				goto noparent;
			if (last->type != F_DIR || last->flags & F_DONE) {
				if (last == root)
					goto noparent;
				last = last->parent;
			}
			last->flags |= F_DONE;
			continue;

noparent:		mtree_err("no parent node");
		}

		plen = strlen(p) + 1;
		if (plen > tnamelen) {
			if ((ntname = realloc(tname, plen)) == NULL)
				mtree_err("realloc: %s", strerror(errno));
			tname = ntname;
			tnamelen = plen;
		}
		if (strunvis(tname, p) == -1)
			mtree_err("strunvis failed on `%s'", p);
		p = tname;

		pathparent = NULL;
		if (strchr(p, '/') != NULL) {
			cur = root;
			for (; (e = strchr(p, '/')) != NULL; p = e+1) {
				if (p == e)
					continue;	/* handle // */
				*e = '\0';
				if (strcmp(p, ".") != 0) {
					while (cur &&
					    strcmp(cur->name, p) != 0) {
						cur = cur->next;
					}
				}
				if (cur == NULL || cur->type != F_DIR) {
					mtree_err("%s: %s", tname,
					"missing directory in specification");
				}
				*e = '/';
				pathparent = cur;
				cur = cur->child;
			}
			if (*p == '\0')
				mtree_err("%s: empty leaf element", tname);
		}

		if ((centry = calloc(1, sizeof(NODE) + strlen(p))) == NULL)
			mtree_err("%s", strerror(errno));
		*centry = ginfo;
		centry->lineno = mtree_lineno;
		strcpy(centry->name, p);
#define	MAGIC	"?*["
		if (strpbrk(p, MAGIC))
			centry->flags |= F_MAGIC;
		set(next, centry);

		if (root == NULL) {
				/*
				 * empty tree
				 */
			if (strcmp(centry->name, ".") != 0 ||
			    centry->type != F_DIR)
				mtree_err(
				    "root node must be the directory `.'");
			last = root = centry;
			root->parent = root;
		} else if (pathparent != NULL) {
				/*
				 * full path entry; add or replace
				 */
			centry->parent = pathparent;
			addchild(pathparent, centry);
			last = centry;
		} else if (strcmp(centry->name, ".") == 0) {
				/*
				 * duplicate "." entry; always replace
				 */
			replacenode(root, centry);
		} else if (last->type == F_DIR && !(last->flags & F_DONE)) {
				/*
				 * new relative child in current dir;
				 * add or replace
				 */
			centry->parent = last;
			addchild(last, centry);
			last = centry;
		} else {
				/*
				 * new relative child in parent dir
				 * (after encountering ".." entry);
				 * add or replace
				 */
			centry->parent = last->parent;
			addchild(last->parent, centry);
			last = centry;
		}
	}
	return (root);
}
Пример #10
0
Файл: exptree.c Проект: pix/cppp
/* Parses a C preprocessor expression from the C source code pointed
 * to by input, via the given lexer, and creates a expression tree
 * representing it. prec gives the precedence of the operator this
 * expression is attached to, or zero if there is no such operator.
 * The return value points to the source immediately following the
 * parsed expression.
 */
static char const *parseexp(struct exptree *t, struct clexer *cl,
			    char const *input, int prec)
{
    struct exptree *x;
    char const *tmp;
    int found, n;

    if (t->exp != expNone)
	return input;

    if (*input == '(') {
	tmp = input;
	input = skipwhite(cl, nextchar(cl, input));
	input = parseexp(t, cl, input, 0);
	if (t->exp == expNone) {
	    error(errSyntax);
	    goto failure;
	} else if (*input != ')') {
	    error(errOpenParenthesis);
	    goto failure;
	}
	t->begin = tmp;
	input = nextchar(cl, input);
	t->end = input;
	input = skipwhite(cl, input);
    } else {
	found = FALSE;
	for (n = 0 ; n < sizearray(prefixops) ; ++n) {
	    if (!memcmp(input, prefixops[n].symbol, prefixops[n].size)) {
		found = TRUE;
		break;
	    }
	}
	if (found) {
	    if (prefixops[n].prec < prec) {
		error(errMissingOperand);
		goto failure;
	    }
	    t->exp = expOperator;
	    t->op = prefixops[n].op;
	    t->begin = input;
	    input = nextchars(cl, input, prefixops[n].size);
	    input = skipwhite(cl, input);
	    x = addnewchild(t, -1);
	    input = parseexp(x, cl, input, prefixops[n].prec);
	    if (x->exp == expNone) {
		error(errSyntax);
		goto failure;
	    }
	    t->end = x->end;
	} else {
	    input = parseconstant(t, cl, input);
	    if (t->exp == expNone) {
		error(errSyntax);
		goto failure;
	    }
	}
    }

    for (;;) {
	found = FALSE;
	for (n = 0 ; n < sizearray(infixops) ; ++n) {
	    if (!memcmp(input, infixops[n].symbol, infixops[n].size)) {
		found = TRUE;
		break;
	    }
	}
	if (!found || infixops[n].prec < prec
		   || (infixops[n].prec == prec && infixops[n].l2r))
	    break;
	input = nextchars(cl, input, infixops[n].size);
	input = skipwhite(cl, input);
	x = initexptree();
	tmp = t->begin;
	*x = *t;
	clearexptree(t);
	t->exp = expOperator;
	t->op = infixops[n].op;
	t->begin = tmp;
	addchild(t, x, -1);
	x = addnewchild(t, -1);
	if (t->op == opConditional) {
	    input = parseexp(x, cl, input, infixops[n].prec);
	    if (x->exp == expNone) {
		error(errSyntax);
		goto failure;
	    }
	    if (*input != ':') {
		error(errSyntax);
		goto failure;
	    }
	    input = skipwhite(cl, nextchar(cl, input));
	    x = addnewchild(t, -1);
	}
	input = parseexp(x, cl, input, infixops[n].prec);
	if (x->exp == expNone) {
	    error(errSyntax);
	    goto failure;
	}
	t->end = x->end;
    }
    return input;

  failure:
    t->exp = expNone;
    return input;
}
Пример #11
0
HMENU user_create_menu(int mid, int flags)
{
	HMENU  m = CreatePopupMenu(), c;
	int i, count, sel_lng;


#	define addmenu(x, i, v)  (InsertMenu(x, (UINT)-1, MF_BYPOSITION | MF_STRING, (i), (v)) )
#	define addmenu_chk(x, i, v)  (InsertMenu(x, (UINT)-1, MF_BYPOSITION | MF_CHECKED | MF_STRING, (i), (v)) )
#	define menugroup(x)      (InsertMenu(x, (UINT)-1, MF_BYPOSITION | MF_SEPARATOR, 0, 0) )
#	define addchild(x, h, v) (InsertMenu(x, (UINT)-1, MF_BYPOSITION | MF_STRING | MF_POPUP, (UINT_PTR)(h), (v)) )
#	define menubegin(x)      (x = CreatePopupMenu())
#	define menuend(x)        (DestroyMenu(x))

	switch(mid)
	{
	case 1:
		{
			struct video_dec *vd;
			letter sub_name[128];

			vdata.shared->call_function(call_video_getvdec, 0, &vd, 0);
			

			menubegin(c);

			addmenu(c, 1001, uni("(None)"));

			count = vd->video_decoder_trans_info(video_get_sub_language_count, 0, 0, 0);
				
			/* get primary language id */
			sel_lng = vd->video_decoder_trans_info(video_get_sub_language_current, 0, 0, 0);

			for(i=0; i<count; i++)
			{
				vd->video_decoder_trans_info(video_get_sub_language_current, i, 0, sub_name);

				if(i != sel_lng)
					addmenu(c, 2000 + i, sub_name);
				else
					addmenu_chk(c, 2000 + i, sub_name);
			}

			addchild(m, c, uni("Primary"));

			menubegin(c);

			addmenu(c, 1002, uni("(None)"));

			/* get secondary language id */

			sel_lng = vd->video_decoder_trans_info(video_get_sub_language_current, 1, 0, 0);

			for(i=0; i<count; i++)
			{
				vd->video_decoder_trans_info(video_get_sub_language_current, i, 0, sub_name);
				
				if(i != sel_lng)
					addmenu(c, 8000 + i, sub_name);
				else
					addmenu_chk(c, 8000 + i, sub_name);
			}

			addchild(m, c, uni("Secondary"));
		}
		break;
	}

	return m;
}
Пример #12
0
HMENU user_create_menu(int mid, int flags)
{
	HMENU  m = CreatePopupMenu(), c;

#	define addmenu(x, i, v)  (InsertMenu(x, (UINT)-1, MF_BYPOSITION | MF_STRING, (i), (v)) )
#	define menugroup(x)      (InsertMenu(x, (UINT)-1, MF_BYPOSITION | MF_SEPARATOR, 0, 0) )
#	define addchild(x, h, v) (InsertMenu(x, (UINT)-1, MF_BYPOSITION | MF_STRING | MF_POPUP, (UINT_PTR)(h), (v)) )
#	define menubegin(x)      (x = CreatePopupMenu())
#	define menuend(x)        (DestroyMenu(x))

	switch(mid)
	{
	case menu_ml_options:
		
		addmenu(m, mid_repeat_list,   skin.shared->language_text[oooo_skins_repeat_list]);
		addmenu(m, mid_repeat_track,  skin.shared->language_text[oooo_skins_repeat_track]);
		addmenu(m, mid_autoswitching, skin.shared->language_text[oooo_skins_autoswitching]);
		menugroup(m);
		addmenu(m, mid_shuffle, skin.shared->language_text[oooo_skins_shuffle]);
		addmenu(m, mid_switch_sindex, skin.shared->language_text[oooo_skins_display_shuffle_index]);
		menugroup(m);
		
		menubegin(c);

		addmenu(c, midc_title     , skin.shared->language_text[oooo_tag_title]);
		addmenu(c, midc_album     , skin.shared->language_text[oooo_tag_album]);
		addmenu(c, midc_artist    , skin.shared->language_text[oooo_tag_artist]);
		addmenu(c, midc_oartist   , skin.shared->language_text[oooo_tag_origartist]);
		addmenu(c, midc_composer  , skin.shared->language_text[oooo_tag_composer]);
		addmenu(c, midc_lyricist  , skin.shared->language_text[oooo_tag_lyricist]);
		addmenu(c, midc_band      , skin.shared->language_text[oooo_tag_band]);
		addmenu(c, midc_copyright , skin.shared->language_text[oooo_tag_copyright]);
		addmenu(c, midc_publisher , skin.shared->language_text[oooo_tag_publish]);
		addmenu(c, midc_encodedby , skin.shared->language_text[oooo_tag_encodedby]);
		addmenu(c, midc_genre	  , skin.shared->language_text[oooo_tag_genre]);
		addmenu(c, midc_year	  , skin.shared->language_text[oooo_tag_year]);
		addmenu(c, midc_url       , skin.shared->language_text[oooo_tag_url]);
		addmenu(c, midc_ourl	  , skin.shared->language_text[oooo_tag_offiartisturl]);
		addmenu(c, midc_filepath  , skin.shared->language_text[oooo_tag_filepath]);
		addmenu(c, midc_filename  , skin.shared->language_text[oooo_tag_filename]);
		addmenu(c, midc_bpm		  , skin.shared->language_text[oooo_tag_bpm]);
		addmenu(c, midc_track	  , skin.shared->language_text[oooo_tag_tracknum]);
		addmenu(c, midc_index     , skin.shared->language_text[oooo_tag_index]);

		addchild(m, c, skin.shared->language_text[oooo_skins_columns]);

		menuend(c);

		addmenu(m, midc_font      , uni("Select Font"));
		addmenu(m, mid_settings     , skin.shared->language_text[oooo_skins_show_preferences]);

		break;

	case menu_ml_add:
		addmenu(m, mid_addfiles , skin.shared->language_text[oooo_skins_addfiles]);
		addmenu(m, mid_add_dir  , skin.shared->language_text[oooo_skins_addfolders]);
		menugroup(m);
		addmenu(m, mid_add_mlib , skin.shared->language_text[oooo_skins_addtoml]);
		break;

	case menu_ml_save:
		addmenu(m, mid_savepl, skin.shared->language_text[oooo_skins_save_playlist]);
		menugroup(m);
		addmenu(m, mid_import, skin.shared->language_text[oooo_skins_import_ml]);
		addmenu(m, mid_export, skin.shared->language_text[oooo_skins_export_ml]);
		break;

	case menu_ml_remove:
		addmenu(m, mid_removesel, skin.shared->language_text[oooo_skins_remove_sel]);
		addmenu(m, mid_removeall, skin.shared->language_text[oooo_skins_clear_playlist]);
		menugroup(m);
		addmenu(m, mid_removeml,  skin.shared->language_text[oooo_skins_clearml]);
		break;

	case menu_ml_sort:
		addmenu(m, mid_sort_filename, skin.shared->language_text[oooo_skins_sort_by_filename]);
		addmenu(m, mid_unsort,        skin.shared->language_text[oooo_skins_sort_unsort]);
		break;

	case menu_ml_popup:
		addmenu(m, mid_edittags,   skin.shared->language_text[oooo_skins_edit_tags]);
		addmenu(m, mid_removesel,  skin.shared->language_text[oooo_skins_remove_sel]);
		menugroup(m);
		addmenu(m, mid_preview,    uni("Preview"));
		addmenu(m, mid_preview_stop,    uni("Stop preview"));

		if(flags == 1) /* media library */
		{
			addmenu(m, mid_addtoplaylist,  skin.shared->language_text[oooo_skins_addtoplaylist]);
		}
		break;


	case menu_open:
		{
			letter exptext[256];

			str_cpy(exptext, skin.shared->language_text[oooo_skins_open]);
			str_cat(exptext, uni(" (experimental)"));

			addmenu(m, mid_addfiles,     skin.shared->language_text[oooo_skins_addfiles]);
			addmenu(m, mid_adddirs,      skin.shared->language_text[oooo_skins_addfolders]);
			menugroup(m);
			addmenu(m, mid_loadtracks,   skin.shared->language_text[oooo_menu_load_tracks]);
			menugroup(m);
			addmenu(m, mid_tray,         skin.shared->language_text[oooo_menu_eject_load]);
			addmenu(m, mid_seldrive,     skin.shared->language_text[oooo_menu_select_drive]);
			menugroup(m);
			addmenu(m, mid_experimental, exptext);
		}
		break;
	}

	return m;
}
Пример #13
0
/*
 * Spawn (create) a new child process for "cmd".
 */
int
spawn(struct cmd *cmd, struct cmd *cmdlist)
{
	pid_t pid;
	int fildes[2];
	char *childname = cmd->c_name;

	if (pipe(fildes) < 0) {
		error("Cannot create pipe for %s: %s", childname, SYSERR);
		return(-1);
	}

	pid = fork();
	if (pid == (pid_t)-1) {
		error("Cannot spawn child for %s: fork failed: %s", 
		      childname, SYSERR);
		return(-1);
	} else if (pid > 0) {
		/*
		 * Parent
		 */
		static CHILD newchild;

#if	defined(FORK_MISSES)
		/*
		 * XXX Some OS's have a bug where fork does not
		 * always return properly to the parent
		 * when a number of forks are done very quicky.
		 */
		sleep(2);
#endif	/* FORK_MISSES */

		/* Receive notification when the child exits */
		(void) signal(SIGCHLD, reap);

		/* Settup the new child */
		newchild.c_next = NULL;
		newchild.c_name = childname;
		newchild.c_readfd = fildes[PIPE_READ];
		newchild.c_pid = pid;
		newchild.c_state = PSrunning;

		/* We're not going to write to the child */
		(void) close(fildes[PIPE_WRITE]);

		/* Set non-blocking I/O */
		if (setnonblocking(newchild.c_readfd, TRUE) < 0) {
			error("Set nonblocking I/O failed: %s", SYSERR);
			return(-1);
		}

		/* Add new child to child list */
		addchild(&newchild);

		/* Mark all other entries for this host as assigned */
		markassigned(cmd, cmdlist);

		debugmsg(DM_CALL,
			 "spawn() Forked child %d for host %s active = %d\n",
			 pid, childname, activechildren);
		return(pid);
	} else {
		/* 
		 * Child 
		 */

		/* We're not going to read from our parent */
		(void) close(fildes[PIPE_READ]);

		/* Make stdout and stderr go to PIPE_WRITE (our parent) */
		if (dup2(fildes[PIPE_WRITE], (int)fileno(stdout)) < 0) {
			error("Cannot duplicate stdout file descriptor: %s", 
			      SYSERR);
			return(-1);
		}
		if (dup2(fildes[PIPE_WRITE], (int)fileno(stderr)) < 0) {
			error("Cannot duplicate stderr file descriptor: %s", 
			      SYSERR);
			return(-1);
		}

		return(0);
	}
}
Пример #14
0
/*
  load a node from the file
  Params: fp - the input stream
          error - return for error
  Returns: node loaded.
  Notes: recursive. Expects the opening parenthesis to have been eaten
 */
static NEWICKNODE *loadnode(FILE *fp, int *error)
{
  NEWICKNODE *answer;
  int err;
  NEWICKNODE *child = 0;
  int ch;

  answer = malloc(sizeof(NEWICKNODE));
  if(!answer)
  {
    err = -1;
    goto error_exit;
  }

  answer->Nchildren = 0;
  answer->label = 0;
  answer->child = 0;
  answer->hv1 = 0;
  answer->hv2 = 0;

  skipspace(fp);
  do
  {
    ch = fgetc(fp);
    if(ch == '(')
    {
      child = loadnode(fp, &err);
      if(!child)
        goto error_exit;

      if( addchild(answer, child ) == -1)
      {
        err = -1;
        goto error_exit;
      }
      child = 0;
    }
    else
    {
      ungetc(ch, fp);
      child = loadleaf(fp, &err);
      if(!child)
        goto error_exit;

      if(addchild(answer, child) == -1)
      {
        err = -1;
        goto error_exit;
      }
      child = 0;
    }
    skipspace(fp);
    ch = fgetc(fp);
  } while(ch == ',');

  if(ch == ')')
  {
    answer->label = readlabelandweight(fp, &answer->weight, &err);
    if(err)
      goto error_exit;
  }
  else
  {
    err = -2;
    goto error_exit;
  }
  
  if(error)
    *error = 0;
  return answer;
 error_exit:
  if(child)
    killnoder(child);
  killnoder(answer);
  if(error)
    *error = err;
  return 0;
}
Пример #15
0
// ---------------------------------------------------------------------
void Form::addmenu()
{
  menubar= new Menus("menu","",this,0);
  addchild((Child *) menubar);
  layout->insertWidget(0,child->widget);
}
Пример #16
0
Add_Child::Add_Child(QWidget *parent)
:QDialog(parent){
this->track_subfield=0;
this->track_tabchild=0;
this->track_tabchild++;
this->track_tabsibling=0;
this->setWindowTitle(tr("Add Child"));
this->setModal(false);
QLabel *Label = new QLabel(tr("Please Enter the name for the child:"));
QLabel *Label1 = new QLabel(tr("Enter Name:"));
inputsLayout = new QVBoxLayout;
QHBoxLayout *hbox = new QHBoxLayout;
QHBoxLayout *hbox1 = new QHBoxLayout;
QHBoxLayout *hbox2 = new QHBoxLayout;
ChildName = new QLineEdit();
ChildName->setMaximumWidth(100);
ChildName->setMinimumWidth(100);
ChildName->setFocusPolicy(Qt::StrongFocus);

///Ok Button Initialization

okButton = new QPushButton(tr("Ok"));
connect(okButton,SIGNAL(clicked()),this,SLOT(accept()));
okButton->setDefault(false);
okButton->setAutoDefault(false);

///cancelButton Initialization

cancelButton = new QPushButton(tr("Cancel"));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
cancelButton->setDefault(false);
cancelButton->setAutoDefault(false);


/// Addsubfield Button Initialization


addSubField = new QPushButton(tr("Add SubFields"));
connect(addSubField, SIGNAL(clicked()), this, SLOT(addsubfield()));
addSubField->setDefault(false);
addSubField->setAutoDefault(false);



///  AddFeature Button Initialization


addFeature = new QPushButton(tr("Add Features"));
connect(addFeature, SIGNAL(clicked()), this, SLOT(addfeature()));
addFeature->setDefault(false);
addFeature->setAutoDefault(false);

///SaveButton Initialization

saveButton = new QPushButton(tr("Save"));
connect(saveButton, SIGNAL(clicked()), this, SLOT(save()));
saveButton->setDefault(false);
saveButton->setAutoDefault(false);



//Delete Button Initialized


deleteButton = new QPushButton(tr("Delete Subfield"));
connect(deleteButton, SIGNAL(clicked()), this, SLOT(remSubField()));
deleteButton->setDefault(false);
deleteButton->setAutoDefault(false);

// Add Child Button Initialized

addChild = new QPushButton(tr("Add Child"));
connect(addChild,SIGNAL(clicked()),this,SLOT(addchild()));
addChild->setDefault(false);
addChild->setAutoDefault(false);


 inputsLayout->addWidget(Label);
hbox->addWidget(Label1);
hbox->addWidget(ChildName);
 inputsLayout->addLayout(hbox);
hbox1->addWidget(addSubField);
hbox1->addWidget(addFeature);
hbox1->addWidget(saveButton);
hbox1->addWidget(deleteButton);
hbox1->addWidget(addChild);
hbox2->addWidget(okButton);
hbox2->addWidget(cancelButton);
 inputsLayout->addLayout(hbox1);
 inputsLayout->addLayout(hbox2);
this->setLayout( inputsLayout);









}
Пример #17
0
NEWICKNODE *TreeOPE::parsenode(char **str, int *error)
{
    NEWICKNODE *answer = NULL;
    int err;
    NEWICKNODE *child = NULL;

    answer = (NEWICKNODE *) malloc(sizeof(NEWICKNODE));
    if (!answer)
    {
        err = -1;
        goto error_exit;
    }

    answer->Nchildren = 0;
    answer->label = NULL;
    answer->child = NULL;
    answer->hv1 = 0;
    answer->hv2 = 0;
    answer->bitstr = NULL;

    if (**str == '(')
    {
        (*str)++;
        child = parsenode(str, &err);
        if (!child)
            goto error_exit;

        if (addchild(answer, child) == -1)
        {
            err = -1;
            goto error_exit;
        }
        child = NULL;
    }
    else
    {
        child  = parseleaf(str, &err);
        if (!child)
            goto error_exit;

        if (addchild(answer, child) == -1)
        {
            err = -1;
            goto error_exit;
        }
        child = NULL;
    }

    while(**str ==  ',')
    {
        (*str)++;
        if (**str == '(')
        {
            (*str)++;
            child = parsenode(str, &err);

            if (!child)
                goto error_exit;

            if (addchild(answer, child) == -1)
            {
                err = -1;
                goto error_exit;
            }
            child = NULL;
        }
        else
        {
            child  = parseleaf(str, &err);
            if (!child)
                goto error_exit;

            if (addchild(answer, child) == -1)
            {
                err = -1;
                goto error_exit;
            }
            child = NULL;
        }
    }

    if (**str == ')')
    {
        (*str)++;
        answer->label = parselabelandweight(str, &answer->weight, &err);
        if(err)
            goto error_exit;
    }
    else
    {
        err = -2;
        goto error_exit;
    }

    if (error)
        *error = 0;
    return answer;

error_exit:
    cout << "Wrong in parsenode()!\n\n";//----
    if (child)
        killnoder(child);
    killnoder(answer);

    if (error)
        *error = err;
    return NULL;
}