示例#1
0
void Format( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, CPTREE& aTree ) throw( IO_ERROR )
{
    if( aTree.size() == 1 && !aTree.data().size() )
    {
        // The topmost node is basically only a container for the document root.
        // It anchors the paths which traverse the tree deeper.
        CITER   it = aTree.begin();
        formatNode( out, aNestLevel, aCtl, it->first, it->second );
    }
    else
    {
        // This is not expected, neither for sexpr nor xml.
        formatNode( out, aNestLevel, aCtl, "", aTree );
    }
}
示例#2
0
static void formatList( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, CPTREE& aTree )

{
    for( CITER it = aTree.begin();  it != aTree.end();  ++it )
    {
        // Processing a tree which was read in with xml_parser?
        if( it->first == "<xmlattr>" )
        {
            formatList( out, aNestLevel, aCtl | CTL_IN_ATTRS, it->second );
            continue;
        }

        int ctl = 0;

        if( isLast( aTree, it ) )   // is "it" the last one?
        {
            //if( !( aCtl & CTL_IN_ATTRS ) )
                ctl = CTL_OMIT_NL;
        }
        else if( isAtom( next( it )->second ) )
        {
            /* if( !( aCtl & CTL_IN_ATTRS ) ) */
                ctl = CTL_OMIT_NL;
        }

        formatNode( out, aNestLevel+1, ctl, it->first, it->second );
    }
}
示例#3
0
void GLUI_TreePanel::update_all() 
{
  printf("GLUI_TreePanel::update_all() doesn't work yet. - JVK\n");
  return;
  GLUI_Panel *saved_root = curr_root;
  GLUI_Tree *saved_branch = curr_branch;
  root_children = 0;
  resetToRoot(this);
  if (curr_branch && dynamic_cast<GLUI_Tree*>(curr_branch))
    formatNode((GLUI_Tree *)curr_branch);
  next();
  while (curr_root && curr_branch != this->first_child()) {
    if (curr_branch && dynamic_cast<GLUI_Tree*>(curr_branch)) {
      formatNode((GLUI_Tree *)curr_branch);
    }
    next();
  } 
  curr_root = saved_root;
  curr_branch = saved_branch;
}
示例#4
0
// ---------------------------------------------------------------------------
//  ContentSpecNode: Miscellaneous
// ---------------------------------------------------------------------------
void ContentSpecNode::formatSpec(XMLBuffer&      bufToFill) const
{
    // Clean out the buffer first
    bufToFill.reset();

    if (fType == ContentSpecNode::Leaf)
        bufToFill.append(chOpenParen);
    formatNode
    (
        this
        , UnknownType
        , bufToFill
    );
    if (fType == ContentSpecNode::Leaf)
        bufToFill.append(chCloseParen);
}
示例#5
0
/* Adds branch to curr_root */
GLUI_Tree *GLUI_TreePanel::ab(const char *name, GLUI_Tree *root) 
{
  GLUI_Tree *temp;

  
  if (root != NULL) {
    resetToRoot(root);
  }

  temp = new GLUI_Tree(curr_root, name);
  initNode(temp);
  formatNode(temp);

  curr_root = temp;
  curr_branch = NULL; /* Currently at leaf */

  if (dynamic_cast<GLUI_Tree*>(temp))
    ((GLUI_Tree *)temp)->set_current(true);
  //refresh();
  //  glui->deactivate_current_control();
  //glui->activate_control( temp, GLUI_ACTIVATE_TAB );
  return temp;

}
示例#6
0
// ---------------------------------------------------------------------------
//  Local methods
// ---------------------------------------------------------------------------
static void formatNode( const   ContentSpecNode* const      curNode
                        , const ContentSpecNode::NodeTypes  parentType
                        ,       XMLBuffer&                  bufToFill)
{
    if (!curNode)
        return;

    const ContentSpecNode* first = curNode->getFirst();
    const ContentSpecNode* second = curNode->getSecond();
    const ContentSpecNode::NodeTypes curType = curNode->getType();

    // Get the type of the first node
    const ContentSpecNode::NodeTypes firstType = first ?
                                                 first->getType() :
                                                 ContentSpecNode::Leaf;

    // Calculate the parens flag for the rep nodes
    bool doRepParens = false;
    if (((firstType != ContentSpecNode::Leaf)
            && (parentType != ContentSpecNode::UnknownType))
    ||  ((firstType == ContentSpecNode::Leaf)
            && (parentType == ContentSpecNode::UnknownType)))
    {
        doRepParens = true;
    }

    // Now handle our type
    switch(curType & 0x0f)
    {
        case ContentSpecNode::Leaf :
            if (curNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId)
                bufToFill.append(XMLElementDecl::fgPCDataElemName);
            else
            {
                bufToFill.append(curNode->getElement()->getRawName());
                // show the + and * modifiers also when we have a non-infinite number of repetitions
                if(curNode->getMinOccurs()==0 && (curNode->getMaxOccurs()==-1 || curNode->getMaxOccurs()>1))
                    bufToFill.append(chAsterisk);
                else if(curNode->getMinOccurs()==0 && curNode->getMaxOccurs()==1)
                    bufToFill.append(chQuestion);
                else if(curNode->getMinOccurs()==1 && (curNode->getMaxOccurs()==-1 || curNode->getMaxOccurs()>1))
                    bufToFill.append(chPlus);
            }
            break;

        case ContentSpecNode::ZeroOrOne :
            if (doRepParens)
                bufToFill.append(chOpenParen);
            formatNode(first, curType, bufToFill);
            if (doRepParens)
                bufToFill.append(chCloseParen);
            bufToFill.append(chQuestion);
            break;

        case ContentSpecNode::ZeroOrMore :
            if (doRepParens)
                bufToFill.append(chOpenParen);
            formatNode(first, curType, bufToFill);
            if (doRepParens)
                bufToFill.append(chCloseParen);
            bufToFill.append(chAsterisk);
            break;

        case ContentSpecNode::OneOrMore :
            if (doRepParens)
                bufToFill.append(chOpenParen);
            formatNode(first, curType, bufToFill);
            if (doRepParens)
                bufToFill.append(chCloseParen);
            bufToFill.append(chPlus);
            break;

        case ContentSpecNode::Choice :
            if ((parentType & 0x0f) != (curType & 0x0f))
                bufToFill.append(chOpenParen);
            formatNode(first, curType, bufToFill);
            if(second!=NULL)
            {
                bufToFill.append(chPipe);
                formatNode(second, curType, bufToFill);
            }
            if ((parentType & 0x0f) != (curType & 0x0f))
                bufToFill.append(chCloseParen);
            break;

        case ContentSpecNode::Sequence :
            if ((parentType & 0x0f) != (curType & 0x0f))
                bufToFill.append(chOpenParen);
            formatNode(first, curType, bufToFill);
            if(second!=NULL)
            {
                bufToFill.append(chComma);
                formatNode(second, curType, bufToFill);
            }
            if ((parentType & 0x0f) != (curType & 0x0f))
                bufToFill.append(chCloseParen);
            break;

        case ContentSpecNode::All :
            if ((parentType & 0x0f) != (curType & 0x0f))
			{
                bufToFill.append(chLatin_A);
                bufToFill.append(chLatin_l);
                bufToFill.append(chLatin_l);
                bufToFill.append(chOpenParen);
			}
            formatNode(first, curType, bufToFill);
            bufToFill.append(chComma);
            formatNode(second, curType, bufToFill);
            if ((parentType & 0x0f) != (curType & 0x0f))
                bufToFill.append(chCloseParen);
            break;
    }
}