YCPPath.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013    File:       YCPPath.h
00014 
00015    Author:     Mathias Kettner <kettner@suse.de>
00016    Maintainer: Thomas Roelz <tom@suse.de>
00017 
00018 /-*/
00019 // -*- c++ -*-
00020 
00021 #ifndef YCPPath_h
00022 #define YCPPath_h
00023 
00024 
00025 #include "YCPValue.h"
00026 #include <y2util/Ustring.h>
00027 
00028 #include "y2/SymbolEntry.h"
00029 
00040 class YCPPathRep : public YCPValueRep
00041 {
00042     struct Component
00043     {
00044         Ustring component; // component string
00045         bool complex;     // true if component is quoted by " in source. false otherwise (component contains only a-zA-Z0-9-_)
00046         Component() : component (SymbolEntry::emptyUstring), complex (false) {}
00047         Component(string s);  // for initial creation. Unquotes and unescapes
00048         Component(bytecodeistream & str);  // for initial creation
00049         int compare(const Component&to) const {
00050             return component.asString().compare(to.component.asString());
00051         }
00052         string toString() const;
00053         std::ostream & toStream (std::ostream & str) const;
00054         std::ostream & toXml (std::ostream & str, int indent ) const;
00055     };
00056 
00057     vector<Component> components;
00058 
00059 protected:
00060     friend class YCPPath;
00061 
00066     YCPPathRep();
00067 
00071     YCPPathRep(const char *r);
00072 
00076     void append(const Component&c);
00077 public:
00078 
00082     bool isRoot() const;
00083 
00092     YCPValue select(const YCPValue& val);
00093 
00097     void append(const YCPPath&p);
00098 
00102     void append(string c);
00103 
00108     long length() const;
00109 
00117     bool isPrefixOf(const YCPPath& p) const;
00118 
00124     YCPPath at(long index) const;
00125 
00130     string component_str(long index) const;
00131 
00139     YCPOrder compare(const YCPPath &v) const;
00140 
00147     string toString() const;
00148 
00152     std::ostream & toStream (std::ostream & str) const;
00153     std::ostream & toXml (std::ostream & str, int indent ) const;
00154 
00158     YCPValueType valuetype() const;
00159 };
00160 
00167 class YCPPath : public YCPValue
00168 {
00169     DEF_COMMON(Path, Value);
00170 public:
00171     YCPPath() : YCPValue(new YCPPathRep()) {}
00172     YCPPath(const char *r) : YCPValue(new YCPPathRep(r)) {}
00173     YCPPath(string s) : YCPValue(new YCPPathRep(s.c_str())) {}
00174     YCPPath(bytecodeistream & str);
00175 };
00176 
00177 #endif   // YCPPath_h

Generated on Tue Nov 6 01:27:46 2007 for yast2-core by  doxygen 1.5.3