标签: namespaces

Doxygen python链接到函数

我正在使用Doxygen来记录我的python模块,我试图让它链接到文本中的函数.我可以将它链接到函数的命名空间ok,但不能链接到函数本身.

ModuleName::Namespace工作,但ModuleName::Namespace::getSomething()没有.

如何让这些链接起作用?

python documentation doxygen namespaces module

0
推荐指数
1
解决办法
2379
查看次数

Python XPath / libxml2名称空间查询

我一直在尝试解析London Underground Linestatus XML“提要”-收效甚微。我本来希望使用XPath可以“轻松”,但是我得到的是空节点。

我相当确定我不会正确处理uk名称空间。

这是我的(相当简单的代码):

import libxml2
from urllib2 import urlopen

data = urlopen('http://cloud.tfl.gov.uk/TrackerNet/LineStatus').read()

try:
    doc = libxml2.parseDoc(data)
except (libxml2.parserError, TypeError):
    print "Problems loading XML"

context = doc.xpathNewContext()
context.xpathRegisterNs("uk", "http://webservices.lul.co.uk")

record_nodes = context.xpathEval('//uk:LineStatus')

for node in record_nodes:
    print "******************************"
Run Code Online (Sandbox Code Playgroud)

record_nodes循环被忽略。xml已正确解析。

有人可以说明一下吗?

python xpath namespaces libxml2 contextpath

0
推荐指数
1
解决办法
775
查看次数

Php扩展zip,ZipArchive不适用于名称空间

示例代码:

namespace myns;

$zip = new ZipArchive;
$zip->open('/var/www/less/less_1.zip');

for ($i = 0; $i < $zip->numFiles; $i++) {
    echo $zip->getNameIndex($i);
}
Run Code Online (Sandbox Code Playgroud)

当我尝试创建命名空间并使用ZipArchive时,我有一个错误:

PHP Fatal error:  Class 'myns\ZipArchive' not found 
in /var/www/less/test.php on line 4
Run Code Online (Sandbox Code Playgroud)

没有命名空间'myns'它工作正常.

我会很感激任何想法.

php namespaces pecl ziparchive

0
推荐指数
1
解决办法
3061
查看次数

未明确引用`(匿名命名空间)::

我有一个名称空间,我目前在两个类中使用.当我尝试编译我的项目时,我得到了该错误,但我的命名空间不是匿名的!

我的一个类看起来像这样:

//margin.cpp
#include <math.h>
#include "margin.h"
#include "anotherClass.h"
#include "specificMath.nsp.h" //My namespace

double margin::doSomeMath(double a, double b){
    return specificMath::math_function1(0, 1, 0);
    // Just a simpler, random example
} 
Run Code Online (Sandbox Code Playgroud)

我的命名空间如下所示:

//specificMath.nsp.h
#ifndef specificMath
#define specificMath
namespace specificMath {
     double math_function1(double, double, double);
     double math_function1(double);
     //more functions
}
Run Code Online (Sandbox Code Playgroud)
 //specificMath.nsp.cpp
 #include <stdlib.h>
 #include "constants.h"
 #include "specificMath.nsp.h"

 namespace specificMath{
     double math_function1(double a, double b, double c){
          //some code
     }
     ... more functions
 }
Run Code Online (Sandbox Code Playgroud)

当我尝试编译时,似乎编译正常,但在链接时(我一直在做"make clean"以确保它使用新文件)我得到一个错误说:

margin.o: In function `margin::doSomeMath(double, double)':
margin.cpp:(.text+0x3d): undefined reference …
Run Code Online (Sandbox Code Playgroud)

c++ namespaces compilation

0
推荐指数
1
解决办法
2289
查看次数

全局命名空间变量?

我想做点什么

(function( skillet, $, undefined ) {

skillet.global = {

   names: { 

      first: 'abe',
      last: 'watson'

   },
   addresses: {
      home: 'blah'
   }

}

}( window.skillet = window.skillet || {}, jQuery ));
Run Code Online (Sandbox Code Playgroud)

这样我就可以访问了

skillet.global.names.first();
skillet.global.address.home();
Run Code Online (Sandbox Code Playgroud)

但我一直在收到错误?我怎样才能解决这个问题

javascript jquery namespaces

0
推荐指数
1
解决办法
94
查看次数

std :: string vs string

我在我的代码中使用了许多名称空间,包括std,所以当我想在我的代码中声明一个字符串变量时,我应该精确地使用std :: string或者我可以放置字符串:

#include <string.h> 

using namespace std;
using namespace boost;
using namespace xerces;

int main()
{
    /*! should I declare my str like this */
    std::string str;
    /*! or I can declare it like this */
    string str1;
    cout << str << str1 <<endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ string namespaces std

0
推荐指数
2
解决办法
4461
查看次数

使用静态初始化的副作用进行一次性初始化

我想在共享库中初始化一些查找表,我想看看这是否是一种有效的方式,如果它继续在更多的库中使用它我将要编写.

typedef std::map<std::string, int> NAME_LUT;
NAME_LUT g_mLUT;
namespace
{
    bool OneTimeInit() 
    {
        ::g_mLUT.insert(NAME_LUT::value_type("open",          1));
        ::g_mLUT.insert(NAME_LUT::value_type("close",         2));
        return true;
    }
    bool bInit = OneTimeInit(); // Just to make initialization happen
}
Run Code Online (Sandbox Code Playgroud)

它似乎在Visual Studio和gcc(Linux)上都能正常工作.只有gcc抱怨bInit没有在任何地方使用.

  1. 是否可能优化初始化(bInit未使用),或语言不允许(由于副作用).
  2. 它确实看起来像处理一次性初始化的良好的跨平台方式,但我不确定这是否是最好的方法.
  3. OneTimeInit声明静态是否有意义?(即使用static bool OneTimeInit() {...}),或单独使用命名空间是使其成为此编译单元唯一的更好方法

c++ namespaces initialization shared-libraries

0
推荐指数
1
解决办法
1521
查看次数

PHP名称空间和继承

我想扩展标准PDO类.所以我有:

namespace Example;

class NewPDO extends PDO {}
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

致命错误:4行的/home/hdocs/lab/index.php中找不到类'Example\PDO'

我知道这是因为PDO类不在Example命名空间内.
我该怎么解决?

php inheritance namespaces

0
推荐指数
1
解决办法
743
查看次数

如何在不使用'using'的情况下缩短C++头文件中的命名空间缩进?

如果使用名称空间来分隔模块/结构化,则头文件中的嵌套和缩进会显着增加.有没有办法以较短的方式编写以下代码?

namespace A
{
    namespace B
    {
        namespace C
        {
            namespace D
            {
                namespace E
                {
                    template <typename T>
                    public class X
                    {
                        public: ...
Run Code Online (Sandbox Code Playgroud)

例如喜欢

namespace A::B::C::D::E
{
  template<typename T> ...
}
Run Code Online (Sandbox Code Playgroud)

在c ++的头文件中?

c++ coding-style namespaces

0
推荐指数
1
解决办法
1152
查看次数

C++命名空间问题

我有三个类,所有这些类都来自不同的命名空间,如下所示:

classA.h

namespace outer
{
    namespace inner
    {
        class ClassA
        {
           ....
        };
    }
}
Run Code Online (Sandbox Code Playgroud)

classB.h

namespace inner
{
    class ClassB
    {
        ...
    };
}
Run Code Online (Sandbox Code Playgroud)

classC.h

#include <classB.h>

namespace outer
{
    namespace inner2
    {
        using inner::ClassB; // error here, says outer::inner2::ClassB has not been declared.

        class ClassC
        {
            ....
        };
     }
}
Run Code Online (Sandbox Code Playgroud)

我被困在这,请帮我解决这个问题.

c++ namespaces

0
推荐指数
1
解决办法
149
查看次数