我正在使用Doxygen来记录我的python模块,我试图让它链接到文本中的函数.我可以将它链接到函数的命名空间ok,但不能链接到函数本身.
如ModuleName::Namespace工作,但ModuleName::Namespace::getSomething()没有.
如何让这些链接起作用?
我一直在尝试解析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已正确解析。
有人可以说明一下吗?
示例代码:
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'它工作正常.
我会很感激任何想法.
我有一个名称空间,我目前在两个类中使用.当我尝试编译我的项目时,我得到了该错误,但我的命名空间不是匿名的!
我的一个类看起来像这样:
//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) 我想做点什么
(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)
但我一直在收到错误?我怎样才能解决这个问题
我在我的代码中使用了许多名称空间,包括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) 我想在共享库中初始化一些查找表,我想看看这是否是一种有效的方式,如果它继续在更多的库中使用它我将要编写.
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没有在任何地方使用.
bInit未使用),或语言不允许(由于副作用).OneTimeInit声明静态是否有意义?(即使用static bool OneTimeInit() {...}),或单独使用命名空间是使其成为此编译单元唯一的更好方法我想扩展标准PDO类.所以我有:
namespace Example;
class NewPDO extends PDO {}
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
致命错误:第4行的/home/hdocs/lab/index.php中找不到类'Example\PDO'
我知道这是因为PDO类不在Example命名空间内.
我该怎么解决?
如果使用名称空间来分隔模块/结构化,则头文件中的嵌套和缩进会显着增加.有没有办法以较短的方式编写以下代码?
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 ++的头文件中?
我有三个类,所有这些类都来自不同的命名空间,如下所示:
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)
我被困在这,请帮我解决这个问题.
namespaces ×10
c++ ×5
php ×2
python ×2
coding-style ×1
compilation ×1
contextpath ×1
doxygen ×1
inheritance ×1
javascript ×1
jquery ×1
libxml2 ×1
module ×1
pecl ×1
std ×1
string ×1
xpath ×1
ziparchive ×1