| 1856 | } |
| 1857 | |
| 1858 | std::vector<std::pair<AbstractMenuItem *, std::list<AbstractMenuItem>::iterator> > |
| 1859 | AbstractMenu::find_item (tl::Extractor &extr) |
| 1860 | { |
| 1861 | typedef std::vector<std::pair<AbstractMenuItem *, std::list<AbstractMenuItem>::iterator> > path_type; |
| 1862 | path_type path; |
| 1863 | |
| 1864 | AbstractMenuItem *parent = &m_root; |
| 1865 | std::list<AbstractMenuItem>::iterator iter = m_root.children.end (); |
| 1866 | |
| 1867 | while (parent && ! extr.at_end ()) { |
| 1868 | |
| 1869 | if (extr.test (";")) { |
| 1870 | |
| 1871 | break; |
| 1872 | |
| 1873 | } else if (extr.test ("#")) { |
| 1874 | |
| 1875 | unsigned int n = 0; |
| 1876 | extr.try_read (n); |
| 1877 | iter = parent->children.begin (); |
| 1878 | ++n; |
| 1879 | while (--n > 0 && iter != parent->children.end ()) { |
| 1880 | ++iter; |
| 1881 | } |
| 1882 | if (n > 0) { |
| 1883 | return path_type (); |
| 1884 | } |
| 1885 | |
| 1886 | } else { |
| 1887 | |
| 1888 | std::string n; |
| 1889 | extr.read (n, ".;+>("); |
| 1890 | |
| 1891 | if (n.empty ()) { |
| 1892 | |
| 1893 | // skip (avoids infinite loops on wrong paths) |
| 1894 | while (! extr.at_end () && *extr != ';') { |
| 1895 | ++extr; |
| 1896 | } |
| 1897 | |
| 1898 | } else if (n == "begin") { |
| 1899 | |
| 1900 | iter = parent->children.begin (); |
| 1901 | |
| 1902 | } else if (n == "end") { |
| 1903 | |
| 1904 | iter = parent->children.end (); |
| 1905 | |
| 1906 | } else { |
| 1907 | |
| 1908 | std::string nn; |
| 1909 | if (extr.test (">")) { |
| 1910 | extr.read (nn, ".;+>("); |
| 1911 | } |
| 1912 | |
| 1913 | std::string name (parent->name ()); |
| 1914 | if (! name.empty ()) { |
| 1915 | name += "."; |
nothing calls this directly
no test coverage detected