src/xpath.h

См. документацию.
00001 //
00002 // C++ Interface: xpath
00003 //
00004 // Description: 
00005 //
00006 //
00007 // Author: yessss <gennadiyesss@mail.ru>, (C) 2007
00008 //
00009 // Copyright: See COPYING file that comes with this distribution
00010 //
00011 //
00012 #ifndef XPATH_H
00013 #define XPATH_H
00014 
00015 #include <string>
00016 #include <list>
00017 
00022 typedef enum {
00023      XP_ELEMENT,
00024      XP_ATTR
00025 } XPType;
00026 
00027 class XPathEntry {
00028 public:
00029      XPType type;
00030      std::string text;
00031      XPathEntry(std::string c, XPType tp = XP_ELEMENT): type(tp), text(c) {
00032      }
00033 };
00034 
00035 class XPath: public std::list<XPathEntry> {
00036 public:
00042      inline static bool is_valid_path(const char* path) {
00043           return true;
00044      }
00045      XPath(const char* path) {
00046           const char* it = path;
00047           const char* it1 = path;
00048           is_valid_path(path);
00049           for(; *it != 0;it++) {
00050                if(*it == '/') {
00051                     if(*it1 == '/')
00052                          it1 = it + 1;
00053                     else {
00054                          push_back(std::string(it1, (int)(it - it1)));
00055                          it1 = it + 1;
00056                     }
00057                }
00058           }
00059           for(const char* i = it1; i != it; i++)
00060                if(*i == '@') {
00061                     push_back(std::string(it1, (int)(i - it1)));
00062                     it1 = i;
00063                }
00064           if(*it1 == '@') {
00065                it1++;
00066                XPathEntry pat(std::string(it1, (int)(it - it1)), XP_ATTR);
00067                push_back(pat);
00068           } else
00069                push_back(std::string(it1, (int)(it - it1)));
00070 
00071           iterator i = begin();
00072           iterator ie = end();
00073 
00074           for(;i != ie;) {
00075                if(i->text == ".")
00076                     i = erase(i);
00077 /*             else if(i->text == "..") {
00078                     iterator t = i;
00079                     if(t != begin()) {
00080                          t--;
00081                          erase(t);
00082                     }
00083                          i = erase(i);
00084                }*/ else if(i->text.empty())
00085                     i = erase(i);
00086                else
00087                     i++;
00088           }
00089           i = begin();
00090      }
00091 };
00092 
00093 #endif

Документация по XDataServer. Последние изменения: Thu Jul 12 11:49:43 2007. Создано системой  doxygen 1.5.2