<?php $isip_window_title = "ISIP Homepage"; ?>
<?php include("/data/isip/www/templates/documentation/header/header.html"); ?>

<!--#set var="isip_page_title" value="XMLToken" -->
<?php include("/data/isip/www/templates/documentation/body/index_class.html"); ?>
<?php include("/data/isip/www/templates/documentation/body/bar.html"); ?>

<a name="name">
<b>name: <a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h">XMLToken</a></b>

<br><br>

<a name="synopsis">
<b>synopsis:</b>
<br><br>

<blockquote>
<pre> 
g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_mmedia.a

#include &lt;XMLToken.h&gt;

XMLToken();
boolean init(TYPE type, String value, Vector< Pair<String, String> > attrib_array, long token_depth = 0, Integral::CMODE ctype = Integral::RESET);

boolean isA(String value, TYPE type); 
String getAttributeValue(const String arg_name) const;
String toXML() const;

</pre>
</blockquote>

<a name="quick_start">
<b>quick start:</b>
<br><br>

<blockquote>
<pre>
XMLToken token;
token.init(L"xml_tag", START_TAG);
token.addAttribute("attrib_name_1", "attrib_val_1");
token.addAttribute("attrib_name_2", "attrib_val_2");
token.removeAttribute("attrib_name_1");
Console::put(token.toXML());
</pre>
</blockquote>

<a name="description"> 
<b>description:</b>
<br><br>

The XMLToken class is a data structure for storing and manipulating
the smallest units of XML code: start tags ( &lt;tag&gt; ), end tags(
&lt;/tag&gt; ), attributes belonging to those tags (&lt;tag attribute = 'value'&gt; )and character data stored between those tags ( &lt;tag&gt; character data  &lt;/tag&gt;).

<br><br>

<a name="dependencies">
<b>dependencies:</b>
<br><br>

<ul>
  <li> <a href="../../shell/DebugLevel/index.html">DebugLevel</a>
  <li> <a href="../../dstr/Pair/index.html">Pair</a>
  <li> <a href="../../io/Sof/index.html">Sof</a>
  <li> <a href="../../math/scalar/String/index.html">String</a>
  <li> <a href="../../dstr/Vector/index.html">Vector</a>
</ul>

<a name="constants">
<b>public constants:</b>
<br><br>

<ul>
  <li> define the class name:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_00.cc&constant=CLASS_NAME">static const String XMLToken::CLASS_NAME(L"XMLToken");</a></pre>
       
	
  <li> define constants to represent the type of token:
       <pre>enum TYPE { NULL_TAG = 0, START_TAG, END_TAG, CDATA, START_AND_END_TAG, UNHANDLED, DEF_TYPE = NULL_TAG };</pre>
       

</ul>

<a name="error">
<b>error codes:</b>
<br><br>
<ul>
  <li> error code indicating XMLToken class general error:
       <pre><a href="/perl/ifc_document.pl?err=00050900">static const long ERR = 50900;</a></pre>
</ul>

<a name="protected">
<b>protected data:</b>
<br><br>

<ul> <!-- list of categories -->
  <li> The value of the token:
      <pre>String value_d; </pre>
  <li> The type of the token:
      <pre>TYPE type_d; </pre>
  <li> The depth of the token:
      <pre>short int depth_d; </pre>
  <li> The attributes of the token:
      <pre>Vector< Pair<String, String> > attributes_d; </pre>  
  <li> The debug level of the token:
      <pre>DebugLevel debug_level_d;</pre>     
</ul>

<a name="public">
<b>required public methods:</b>
<br><br>

<ul>
  <li> static methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=name">static const String& name();</a></pre>
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=diagnose">static boolean diagnose(Integral::DEBUG debug_level);</a></pre>

  <li> debug methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=setDebug">boolean setDebug(Integral::DEBUG debug_level);</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=debug">boolean debug(const unichar* msg) const;</a></pre>
       
  <li> constructor:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_00.cc&method=default+constructor">XMLToken();</a></pre>
                          
  <li> i/o methods:
       
       <pre>these methods are omitted because XMLToken objects cannot write themselves to an Sof file</pre>

  <li> assign methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_01.cc&method=assign">boolean assign(const XMLToken& arg);</a></pre>

  <li> operator= methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=operator%3D&instance=0">XMLToken& operator=(const XMLToken& token);</a></pre>

  <li> operator== methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=operator%3D%3D&instance=0">XMLToken& operator==(const XMLToken& token);</a></pre>

  <li> equality methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=eq">boolean eq(const XMLToken& xt) const;</a></pre>

  <li> clear methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_01.cc&method=clear">boolean clear(Integral::CMODE ctype);</a></pre>

</ul>

<a name="specific">
<b>class-specific public methods:</b>
<br><br>

<ul>       
  <li> get/set methods:
      
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_05.cc&method=setDepth">boolean setDepth(short int depth);</a></pre>    
   
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=getDepth">long getDepth() const;</a></pre>       

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=setValue">boolean setValue(String value);</a></pre>       

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=getValue">String getValue() const;</a></pre>       

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=setType">boolean setType(TYPE type);</a></pre>       

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=setDebug">boolean setDebug(Integral::DEBUG level);</a></pre>       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=getDebug">DebugLevel getDebug() const;</a></pre>
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=setAttributes">boolean setAttributes(Vector<Pair<String, String> >& attribs);</a></pre>
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_03.cc&method=setAttributes">boolean setAttributes(const byte** attrib_array);</a></pre> 
      
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=getAttributes">Vector< Pair<String, String> > getAttributes();</a></pre>       

  <li> attribute manipulation methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_03.cc&method=addAttribute">boolean addAttribute(String attrib_name, String attrib_value);</a></pre>     

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_03.cc&method=removeAttribute">boolean removeAttribute(String attrib_name);</a></pre>       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=setAttributeValue">boolean setAttributeValue(const String aname, const String avalue);</a></pre>       

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_03.cc&method=getAttributeValue">String getAttributeValue(const String arg_name) const;</a></pre>

  <li> initialization methods:
  
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_05.cc&method=init&instance=0">boolean init(TYPE type, String value, Vector< Pair<String, String> > attrib_array, long token_depth = 0, Integral::CMODE ctype = Integral::RESET);</a></pre>      
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_05.cc&method=init&instance=1">boolean init( TYPE type, String value, long token_depth = 0, Integral::CMODE ctype = Integral::RESET );</a></pre>       

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_05.cc&method=init&instance=2">boolean init( TYPE type, String value, const byte** attrib_array, long token_depth = 0, Integral::CMODE ctype = Integral::RESET )</a></pre>     

  <li> comparison methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_05.cc&method=isA&instance=0">boolean isA(XMLToken::TYPE type);</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_05.cc&method=isA&instance=1">boolean isA(String value);</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_05.cc&method=isA&instance=2">boolean isA(String value, TYPE type);</a></pre>
  
  <li> miscellaneous methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_04.cc&method=toXML">String toXML() const;</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/XMLToken.h&method=isA&instance=2">boolean hasAttributes();</a></pre>

</ul>

<a name="private">
<b>protected methods:</b>
<br><br>

<ul>
  <li> attribute output related methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_04.cc&method=addQuotes">String addQuotes(String attrib) const;</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/mmedia/XMLToken/xt_04.cc&method=concatAttributesAsXML">boolean concatAttributesAsXML(String& output) const;</a></pre>

</ul>

<a name="examples">
<b>examples:</b>
<br><br>

<ul>
  <li> This example shows how to create an XMLToken with a few attributes, change
       the values of those attributes, remove some of the attributes, change the 
       XMLToken's type, and output the XMLToken.
   
<pre>
// initialize a token
//
XMLToken token;
token.init(L"xml_tag", START_TAG);
token.addAttribute("attrib_name1", "attrib_val1");
token.addAttribute("attrib_name2", "attrib_val2");
token.addAttribute("attrib_name3", "attrib_val3");

// displays &lt;xml_tag attrib_name1='attrib_val1' attrib_name2='attrib_val2' attrib_name3='attrib_val3'&gt;
//
if(token.isA(START_TAG, L"xml_tag")) {
  Console::put(token.toXML());
}

// change the value of the attrib_name attribute
//
token.setAttributeValue(L"attrib_name1", L"new_value");

// this will outut the new value: "new_value"
//
Console::put(token.getAttributeValue(L"attrib_name1"));

token.removeAttribute(L"attrib_name2");

// displays &lt;xml_tag attrib_name1='new_value' attrib_name3='attrib_val3'&gt;
//
Console::put(token.toXML());

// change the type of the tag
//
token.setType(END_TAG);

// end tags may not have attributes. displays &lt;/xml_tag&gt;
//
if(!token.isA(START_TAG, L"xml_tag")) {
  Console::put(token.toXML());
}
</pre>
</ul>

<!--#include virtual="/hse/ies/templates/documentation/footer/footer.html" -->
