Cython:使用嵌套 typedef 公开 C++ 类

2023-12-21

根据this https://stackoverflow.com/questions/28382575/are-c-style-internal-typedefs-possible-in-cythonstackoverflow 中的问题/答案,不可能直接在 cython 中重写 C++ 嵌套 typedef。我有这样的问题,我不知道哪种是正确/最佳的继续方式。

让我更具体地举一个例子。下面,您可以找到两个 C++ 文件(一个 header.h 和一个 .cpp)以及两个相应的 cython 文件(一个 .pxd 和一个 .pyx)的内容。在 C++ 头文件中称为cpp_graph.h你可以看到嵌套的 typedef 声明;例如,对应于Graph::iterator::nn_iterator. 我不知道如何在相应的内容中公开这一点graph.pxd file.或者,换句话说,我不知道“官方”或“标准”的做法是什么。

一些相关信息。如果您检查 STL 的 cython 包装器,您可以找到嵌套的 typedef。例如here https://github.com/cython/cython/blob/master/Cython/Includes/libcpp/utility.pxd in the utility.pxd or here https://github.com/cython/cython/blob/master/Cython/Includes/libcpp/vector.pxd in the vector.pxd文件。然而,这些嵌套用法ctypedef仅用于模板声明。嵌套 typedef 是否仅适用于 cython 中的模板声明?

C++头文件:

// file : cpp_graph.h

#ifndef Included_cpp_graph
#define Included_cpp_graph

#include <cassert>
#include <cstddef>
#include <set>
#include <map>
#include <iostream>
#include <string>
#include <sstream>
#include "to_string_patch.h"

#ifndef Defined_bint
#define Defined_bint
typedef int                                          bint;
#endif

class Graph {
    public:
        typedef std::set< int >                      t_nn;
        typedef std::set< int >::iterator            nn_iterator;
        typedef std::map< int , t_nn >               t_node_to_nn;    
        class iterator
        {
            // To iterate over nodes.
            friend class Graph;
            public:
                typedef iterator self_type;
                typedef int value_type;
                typedef int & reference;
                typedef int * pointer;                
                typedef t_node_to_nn::iterator map_iterator; 
                typedef std::forward_iterator_tag iterator_category;
                iterator( map_iterator map_it ) : _map_it( map_it ) { }
                self_type operator++()         { _map_it++; return *this;                  } // PREFIX
                self_type operator++(int junk) { self_type i = *this; _map_it++; return i; } // POSTFIX  
                value_type    operator*()  { return   ( * _map_it ).first;  } // Return the index "i"
                Graph::t_nn * operator->() { return & ( * _map_it ).second; } // Return a pointer to the contained t_nn.
                bool operator==( const self_type & rhs ) { return _map_it == rhs._map_it; }
                bool operator!=( const self_type & rhs ) { return _map_it != rhs._map_it; }
            private:
                map_iterator _map_it;
        };    
        class const_iterator
        {
            friend class Vertex;        
            public:
                typedef const_iterator self_type;
                typedef int value_type;
                typedef int & reference;
                typedef int * pointer;                
                typedef t_node_to_nn::iterator map_iterator;
                typedef std::forward_iterator_tag iterator_category;
                const_iterator( map_iterator map_it ) : _map_it( map_it ) { }
                self_type operator++()         { _map_it++; return *this;                  } // PREFIX
                self_type operator++(int junk) { self_type i = *this; _map_it++; return i; } // POSTFIX 
                const value_type    operator*()  { return   ( * _map_it ).first;  } // Return the index "i"
                const Graph::t_nn * operator->() { return & ( * _map_it ).second; } // Return a pointer to the contained t_nn.
                bool operator==( const self_type& rhs ) { return _map_it == rhs._map_it; }
                bool operator!=( const self_type& rhs ) { return _map_it != rhs._map_it; }
            private:
                map_iterator _map_it;
        };     
        iterator begin() { _node_to_nn.begin(); }
        iterator end()   { _node_to_nn.end();   }        
        const_iterator begin() const { _node_to_nn.begin(); }
        const_iterator end()   const { _node_to_nn.end();   }        
        nn_iterator nn_begin( int i ) { assert( has_node( i ) ); return _node_to_nn[ i ].begin(); }
        nn_iterator nn_end( int i )   { assert( has_node( i ) ); return _node_to_nn[ i ].end();   }
        Graph() : _num_links( 0 ) {}
        ~Graph() { _node_to_nn.clear(); _num_links = 0; }
        Graph & subgraph( std::set< int > & nodes ) {
            Graph * S = new Graph();
            for ( std::set< int >::iterator n_it = nodes.begin() ; n_it != nodes.end() ; n_it++ ) {
                int i = ( * n_it );
                assert( has_node( i ) );
                for ( nn_iterator j_it = nn_begin( i ) ; j_it != nn_end( i ) ; j_it++ ) { 
                    int j = ( * j_it );
                    if ( nodes.count( j ) > 0 ) { S -> add_link( i , j ); }
                }
            }
            return ( * S );
        }
        int num_nodes() { return _node_to_nn.size(); }
        int num_links() { return _num_links; }
        int degree( int i )  { return _node_to_nn[ i ].size(); }
        double avrg_degree() { return ( ( double ) 2 * num_nodes() ) / ( ( double ) _num_links ); }
        bool has_node( int i ) { return _node_to_nn.count( i ) > 0; }
        bool has_nn( int i , int j ) { 
            if ( has_node( i ) ) { return _node_to_nn[ i ].count( j ) > 0; }
            return false;
        }
        bool has_link( int i , int j ) { return has_nn( i , j ); }
        void add_node( int i ) { _node_to_nn[ i ].count( 0 ); } // Trick...
        void add_link( int i , int j ) { 
            if ( has_link( i , j ) ) { return; }
            _node_to_nn[ i ].insert( j );
            _node_to_nn[ j ].insert( i );
            _num_links += 1;
        }
        void del_link( int i , int j ) {
            if ( has_link( i , j ) ) { 
                _node_to_nn[ i ].erase( j );
                _node_to_nn[ j ].erase( i );
                _num_links -= 1;
            }
        }
        void del_node( int i ) { 
            iterator i_it = _node_to_nn.find( i ); 
            for( nn_iterator j_it = i_it -> begin() ; j_it != i_it -> end() ; j_it++ ) { del_link( i , ( * j_it ) ); }
            _node_to_nn.erase( i_it._map_it );
        }
        void clear_node( int i ) { del_node( i ); add_node( i ); } // Trick...
    private:
        t_node_to_nn    _node_to_nn;
        int             _num_links;
};

std::ostream& operator<<( std::ostream& os , Graph & G );

typedef Graph::t_nn Graph_t_nn
typedef 

#endif // Included_cpp_graph

C++ .cpp 文件:

// cpp_graph.cpp

#include <cassert>
#include <cstddef>
#include <set>
#include <map>
#include <iostream>
#include <string>
#include <sstream>
#include "to_string_patch.h"
#include "cpp_graph.h"

std::ostream& operator<<( std::ostream& os , Graph & G ) {    
    os << "Graph{";
    // Print nodes.
    for ( Graph::iterator i_it = G.begin() ; i_it != G.end() ; i_it++ ) {
        int i = ( * i_it );
        os << " " << patch::to_string( i );
    }
    os << " |";
    // Print edges.              
    for ( Graph::iterator i_it = G.begin() ; i_it != G.end() ; i_it++ ) {
        int i = ( * i_it );
        for ( Graph::nn_iterator j_it = G.nn_begin( i ) ; j_it != G.nn_end( i ) ; j_it++ ) {
            int j = ( * j_it );
            if ( i < j ) { os << " " + patch::to_string( i ) << ":" << patch::to_string( j ); }
        }
    }
    os << " }"; // << std::endl;
    return os;
}   

// === For testing purposes ===.
/*
int main() {

    Graph G;   
    G.add_link( 1 , 2 );
    G.add_link( 1 , 3 );
    G.add_link( 2 , 3 );
    G.add_link( 3 , 4 );
    G.add_link( 4 , 5 );                
    G.add_link( 4 , 6 );
    G.add_link( 5 , 6 );            
    std::cout << G << std::endl;

    G.del_link( 3 , 4 );
    std::cout << G << std::endl;    

    G.del_node( 3 );
    std::cout << G << std::endl;    

    G.clear_node( 2 );
    std::cout << G << std::endl;    

    G.add_link( 100 , 101 );
    std::cout << G << std::endl;    
    std::cout << "N = " << G.num_nodes() << " M = " << G.num_links() << std::endl;        

}
*/

cython .pxd 文件:

# file : graph.pxd

# === Cython cimports ===

from libcpp cimport bool
from libcpp.set cimport set as cset
from libcpp.map cimport map as cmap
from cython.operator cimport dereference as deref, preincrement as inc

# === Exposing the C++ Graph class ===

cdef extern from "cpp_graph.h":
    cdef cppclass Graph:
        #public:
        ctypedef cset[ int ]                     t_nn
        ctypedef cset[ int ].iterator            nn_iterator
        ctypedef cmap[ int , t_nn ]              t_node_to_nn
        cppclass iterator:
            #friend class Graph;
            #public:
            typedef iterator self_type
            typedef int value_type
            typedef int & reference
            typedef int * pointer
            typedef t_node_to_nn::iterator map_iterator
            typedef std::forward_iterator_tag iterator_category
            iterator( map_iterator map_it )
            self_type operator++()
            self_type operator++(int junk)
            value_type    operator*()
            Graph::t_nn * operator->()
            bool operator==( const self_type & rhs )
            bool operator!=( const self_type & rhs )
            #private:
            #    map_iterator _map_it;
        cppclass const_iterator:
            #friend class Vertex;        
            #public:
            typedef const_iterator self_type
            typedef int value_type
            typedef int & reference
            typedef int * pointer               
            typedef t_node_to_nn::iterator map_iterator
            typedef std::forward_iterator_tag iterator_category
            const_iterator( map_iterator map_it )
            self_type operator++()
            self_type operator++(int junk)
            const value_type    operator*()
            const Graph::t_nn * operator->()
            bool operator==( const self_type& rhs )
            bool operator!=( const self_type& rhs )
            #private:
            #    map_iterator _map_it;
        iterator begin()
        iterator end()
        const_iterator begin() const
        const_iterator end()   const
        nn_iterator nn_begin( int i )
        nn_iterator nn_end( int i )
        Graph()
        ~Graph()
        Graph & subgraph( std::set< int > & nodes )
        int num_nodes()
        int num_links()
        int degree( int i )
        double avrg_degree()
        bool has_node( int i )
        bool has_nn( int i , int j )
        bool has_link( int i , int j )
        void add_node( int i )
        void add_link( int i , int j )
        void del_link( int i , int j )
        void del_node( int i )
        void clear_node( int i )
        #private:
            #t_node_to_nn    _node_to_nn;
            #int             _num_links;

std::ostream& operator<<( std::ostream& os , Graph & G )

# === Python Wrapper for the C++ Graph class ===

cdef class PyGraph:

    # === Data-members ===

    # Pointer to a C++ Graph object.
    cdef Graph * _c_graph

    # === Function-members ===    

    # @ graph.pyx

和 cython .pyx 文件:

# file : graph.pyx

# === Cython cimports ===

from libcpp cimport bool
from libcpp.set cimport set as cset
from libcpp.map cimport map as cmap
from cython.operator cimport dereference as deref, preincrement as inc

# === Ctypedefs for Graph class ===

# @ graph.pxd

# === Exposing the C++ Graph class ===

cdef extern from "cpp_graph2.h":
    cdef cppclass Graph:
        #public:
        ctypedef cset[ int ]                     t_nn
        ctypedef cset[ int ].iterator            nn_iterator
        ctypedef cmap[ int , t_nn ]              t_node_to_nn
        cppclass iterator:
            #friend class Graph;
            #public:
            typedef iterator self_type
            typedef int value_type
            typedef int & reference
            typedef int * pointer
            typedef t_node_to_nn::iterator map_iterator
            typedef std::forward_iterator_tag iterator_category
            iterator( map_iterator map_it )
            self_type operator++()
            self_type operator++(int junk)
            value_type    operator*()
            Graph::t_nn * operator->()
            bool operator==( const self_type & rhs )
            bool operator!=( const self_type & rhs )
            #private:
            #    map_iterator _map_it;
        cppclass const_iterator:
            #friend class Vertex;        
            #public:
            typedef const_iterator self_type
            typedef int value_type
            typedef int & reference
            typedef int * pointer               
            typedef t_node_to_nn::iterator map_iterator
            typedef std::forward_iterator_tag iterator_category
            const_iterator( map_iterator map_it )
            self_type operator++()
            self_type operator++(int junk)
            const value_type    operator*()
            const Graph::t_nn * operator->()
            bool operator==( const self_type& rhs )
            bool operator!=( const self_type& rhs )
            #private:
            #    map_iterator _map_it;
        iterator begin()
        iterator end()
        const_iterator begin() const
        const_iterator end()   const
        nn_iterator nn_begin( int i )
        nn_iterator nn_end( int i )
        Graph()
        ~Graph()
        Graph & subgraph( std::set< int > & nodes )
        int num_nodes()
        int num_links()
        int degree( int i )
        double avrg_degree()
        bool has_node( int i )
        bool has_nn( int i , int j )
        bool has_link( int i , int j )
        void add_node( int i )
        void add_link( int i , int j )
        void del_link( int i , int j )
        void del_node( int i )
        void clear_node( int i )
        #private:
            #t_node_to_nn    _node_to_nn;
            #int             _num_links;

# === Python Wrapper for the C++ Graph class ===

cdef class PyGraph:

    # === Data-members ===    

    # @ graph.pxd

    # === Function-members ===    

    def __cinit__( self ):

        self._c_graph = new Graph()

    def __dealloc__( self ):

        del self._c_graph

    # TODO : implement the methods for adding and deleting nodes/links.

最后,当我尝试编译/构建它时,出现以下错误:

###########################################################
# setup build_ext...
###########################################################

Error compiling Cython file:
------------------------------------------------------------
...
# === Exposing the C++ Graph class ===

cdef extern from "cpp_graph2.h":
    cdef cppclass Graph:
        #public:
        ctypedef cset[ int ]                     t_nn
       ^
------------------------------------------------------------

ExcessDegreeModel/graph.pxd:51:8: Expected an identifier, found 'ctypedef'
...

我已经使用嵌套定义来工作namespace关键字,指定嵌套声明。就像,如果你有例如名为的 C++ 标头中的以下内容mystuff.hpp:

namespace MyStuff {
    struct Outer {
        struct Inner {
            int value;
        };
        Inner member;
    };
}

...你可以像这样封闭这些结构:

cdef extern from "mystuff.hpp" namespace "MyStuff::Outer":
    cppclass Inner:
        int value

cdef extern from "mystuff.hpp" namespace "MyStuff":
    cppclass Outer:
        Inner member

…如果您实际上将 C++ 领域的所有内容都包装在名称空间中,如所写(否则第二个cdef has no namespace在其声明中,在我看来这看起来更奇怪)。

我有许多现实世界中当前正在使用的示例:一个这样的例子在这里 https://github.com/fish2000/halogen/blob/master/halogen/ext/halide/function.pxd, 另一个在这里 https://github.com/fish2000/halogen/blob/master/halogen/ext/halide/module.pxd.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Cython:使用嵌套 typedef 公开 C++ 类 的相关文章

  • 将数据集导出到 EXCEL

    我使用以下代码将数据库表中的字段导出到 Excel 中 我想要做的是能够编写一条 SQL 语句从多个表中检索字段并将其导出到 Excel 中 这段代码只允许我导出一张表 另外 如何显示保存提示对话框 示例代码将不胜感激 非常感谢 prote
  • 将数组从 C# 编组到 C++ 并返回:PInvokeStackImbalance

    我有一个 C 函数 我想从 C 访问它 问题是我不断收到 PInvokeStackImbalance 异常 但我不知道为什么 当检查异常被关闭时 一切都运行良好并且符合预期 我的 C 函数的签名是 extern C double solve
  • 多个源文件中包含包含“const”的头文件

    Why does not包含定义的头文件const并被多个源文件包含会产生编译错误multiple definition const in header file h const int num 5 int x Error Multiple
  • WPF MVVM将DataTable绑定到DataGrid不显示数据

    我有一个简单的控件 其中包含一个 DataGrid 其中 ItemsSource 绑定到 DataTable 当我填充 DataTable 时 我可以看到 DataGrid 中添加了行 但没有显示任何数据 我没有为此 DataGrid 使用
  • 无法使用 ASP.NET Core 从 JWT 令牌获取声明

    我正在尝试使用 ASP NET Core 实现 JWT 持有者身份验证的非常简单的实现 我从控制器返回的响应有点像这样 var identity new ClaimsIdentity identity AddClaim new Claim
  • 将 try_emplace 与 shared_ptr 一起使用

    所以我有一个std unordered map
  • C# - 如何将 IntPtr 缓冲区数据保存到文件(最快的方法)?

    我使用此代码将非托管代码中的 IntPtr 缓冲区中的字节保存到文件中 这是一个简单的回调函数 private void callback IntPtr buffer int length byte bytes new byte lengt
  • Code First - 实体框架 - 如何公开外键

    我有以下数据对象 public class Customer System Data Entity ModelConfiguration EntityTypeConfiguration
  • c#Registry to XML无效字符问题

    我在尝试从注册表创建 XML 文件时遇到问题 在我的笔记本电脑 W7 64b 上它工作正常 生成了 xml 文件 但在另一台计算机 Xp 32b 上抛出异常 System ArgumentException 十六进制值 0x00 是无效字符
  • 是否可以用 C# 为 Android 编写应用程序?

    我们都知道Android运行Dalvik VM程序 通常开发人员用 Java 编写程序并将其编译为 Dalvik 字节码 我想知道是否有可能创建一个可以接受 C 代码并将其编译为 Dalvik 字节码的编译器 嗯 这是一种选择 或者您可以在
  • popen2()在c中如何工作?

    我尝试使用管道 叉子和 dup 在我的程序中执行 md5sume 命令 我发现总和代码运行成功 但我无法理解某些代码行 这是我的代码 int infp outfp char buf 128 if popen2 md5sum infp out
  • C++ 克隆惯用语中协变返回类型的用处?

    通常的克隆习惯使用协变返回类型 struct Base virtual Base clone struct Derived public Base Derived clone 我读过一些内容 大意是协变返回类型是 C 后来添加的 较旧的编译
  • 让 WIX 在项目中包含引用

    我对 WiX 和设置自定义安装程序完全陌生 所以我对问题的主题表示歉意 我有一个内部业务应用程序 日记 它构建并运行良好 因此我按照教程 官方文档添加 WiX 项目并引用日记的 csproj 然后构建并运行这个最基本版本的 WiX 安装程序
  • 标准头文件中的 C 编译器错误 - 未定义的 C++ 定义

    我正在尝试编译 C 程序 但收到许多错误 这些错误是在标准 C 头文件 inttypes h stdio h stat h 等 中遇到的 错误的来源是以下未定义的常量 BEGIN DECLS END DECLS BEGIN NAMESPAC
  • 在 C# 中加密并在 Flex 中解密

    我需要解密 Flex 中的一些数据 这些数据是用 C 加密并写入文件的 为了简单起见 我选择使用 as3crypto As3 库和 Bruce Schneier C 库 AS3 as3加密链接 http code google com p
  • 如何带参数调用外部程序?

    我想在我的代码中调用一个 Windows 程序 并使用代码本身确定的参数 我不想调用外部函数或方法 而是调用 WinXP 环境中的实际 exe 或批处理 脚本文件 C 或 C 将是首选语言 但如果使用任何其他语言更容易完成此操作 请告诉我
  • 我可以在C中直接比较int和size_t吗?

    我可以比较一个int and a size t像这样的变量 int i 1 size t y 2 if i y Do something 或者我必须输入其中之一 只要满足以下条件 它就是安全的int为零或正数 如果它是负数 并且size t
  • 修改公共属性的访问修饰符是否是重大更改?

    如果我将公共属性的 setter 的访问修饰符从私有更改为公共 是否会导致引用它的其他程序集发生任何重大更改 UPDATE 这个问题是我 2012 年 1 月博客的主题 https ericlippert com 2012 01 09 ev
  • 父窗体中的居中消息框[重复]

    这个问题在这里已经有答案了 有没有一种简单的方法可以在 net 2 0中将MessageBox居中于父窗体中 我在 C 中确实需要这个并发现中心消息框 C http bytes com topic c sharp answers 26712
  • 当另一个进程使用 std::fstream 写入文件时从文件读取[重复]

    这个问题在这里已经有答案了 我需要从文件中逐行读取 它是由 std getline 完成的 另一个进程的问题是一直向其附加数据 然后我需要读取新行 例如 文件一开始包含10行 我的程序读取了10行 那么我的程序应该等待 过了一会儿 另一个进

随机推荐

  • 使用 Postman 对 Django Web 服务进行 Http post 请求(需要登录信息)

    我想向我之前实现的 web 服务发送一个 http 请求 该服务需要用户登录 现在 我实现了一个表单页面来为我执行此操作 我需要针对每个不同的请求更改它 据我所知 Django需要 csrftoken 和 sessionid 来允许请求 不
  • 从 MySQL 中的两个表中选择数据

    我拥有的 下一个结构 表零 gt id 主要具有自动增量 gt 其他 table 1 gt id 表零 id 的外键 gt varchar 80 示例值 aahellobbb gt 一个字段 table 2 gt id 表零 id 的外键
  • Symfony 安全注销未清除 RememberMe 令牌

    将 Symfony 4 与security yaml像这样 encoders App Entity User sha256 providers public users entity class App Entity User proper
  • 即使按下设备的剪切按钮,Midlet 也不能​​关闭

    我在 J2ME 工作 我希望我的 MIDlet 必须运行无限长的时间 即使我按设备上的任何键 它也不能关闭 请帮我解决这个问题我该怎么办 如果您使用的是诺基亚手机 您可以在 Jad 文件中添加 Nokia MIDlet No Exit tr
  • 如何在 ruby​​ 中通过 SSL 调用 HTTP POST 方法?

    这是使用curl 的请求 curl XPOST H content type application json d credentials username username key key https auth api rackspace
  • 循环和科拉茨猜想

    我在循环和声明变量方面遇到问题 目前我正在制作一个关于 Collat z 猜想的程序 该程序应该检查从一定数量的 Collat z 序列中到达一个的最大步骤是什么 这是我的代码 start num int input insert a st
  • 标签是否会被弃用?

    这比任何悬而未决的灾难更令人好奇 D So the b and i 标签从网络诞生之初就已经存在了 我想 但现在我们有了CSS 而且很多人都在使用 风格化的html 标签 它们是风格标签 但它们实际上并没有那么糟糕 因为它们使我们不必制作一
  • PHP中获取字符串的第一行

    在 PHP 5 3 中有一个不错的功能 http www php net manual en function strstr php这似乎做我想做的 strstr input n true 不幸的是 服务器运行 PHP 5 2 17 和可选
  • IBM Watson Visual Recognition - 由于凭证无效,访问被拒绝

    我正在尝试将IBM Watson Visual Recognition 工具与nodejs express 结合使用 我按照指示guide https www ibm com watson developercloud visual rec
  • 如何让bulletphysicals/bulletsharps 的多线程工作?

    也就是说 设置 BulletSharp 物理引擎包装器的 DynamicsWorld 以使用 BulletSharp MultiThreaded ParallelConstraintSolver 所需的最小代码集是什么 或者 我可能可以通过
  • 如何将 ByteString 转换为 Int 并处理字节顺序?

    我需要在 Haskell 中读取二进制格式 格式相当简单 四个八位位组指示数据的长度 后面跟着数据 四个八位位组表示网络字节顺序的整数 我怎样才能转换ByteString四个字节为一个整数 我想要一个直接转换 在 C 语言中 那就是 int
  • Python lambda 与正则表达式

    当在 python 中使用 re 的 re sub 部分时 如果我没有记错的话 可以使用 sub 函数 据我所知 它会将匹配传递给传递的任何函数 例如 r re compile r A Za z r sub function string
  • PTTest 失败并且未生成突变覆盖率

    我想生成突变测试覆盖率 我正在对 PI 测试进行 POC 但这并不是参加我的考试课程而失败 我已经在 pom xml 中配置了 PTTest 插件 我检查了pom xml文件中的目标类包名称和目标测试类包名称是否正确 我遇到以下错误 10
  • 不带 http(s) 前缀的 Href

    我刚刚创建了原始的 html 页面 这里是 example https jsfiddle net yv1661dx 1 这是它的标记 a href www google com www google com a br a href http
  • 如何修复颤动异常:使用不包含导航器的上下文请求导航器操作

    我正在尝试使用 flutter 框架创建抽屉导航 但每次运行时我都会遇到以下异常 抛出另一个异常 使用 a 请求导航器操作 不包含导航器的上下文 那么解决方案是什么 有帮助吗 我使用 Navigator 类如下 void main runA
  • 应用程序在 Android 模拟器上正常工作时无法访问设备上的互联网?

    我开发了一个基于 SIP 的应用程序 该应用程序在 Android 设备上调试时无法使用互联网连接 但在模拟器上调试时却可以正常工作 我已在manifest xml 中授予了有关互联网连接的所有权限 是否有任何其他权限可以使用互联网连接在设
  • OSX - 如何判断光标是否可见

    我知道这个问题已经得到回答 检测 Mac OS X 上光标是否隐藏 https stackoverflow com questions 5026660 detect if cursor is hidden on mac os x 但此时 函
  • Python Pandas 用相反的符号替换值

    我正在尝试 清理 一些数据 我的价值观是负面的 但它们不可能是负面的 我想将所有负值替换为相应的正值 A B C 1 9 0 2 Hello 1 2 0 3 World 我希望这成为 A B C 1 9 0 2 Hello 1 2 0 3
  • Android Studio 布局预览默认主题

    也许这是 Android Studio 中众所周知的选项 但我找不到它 Google 也没有帮助我解决这个问题 每次我在 Android Studio 中打开布局预览时 它都会将 Material Light 主题应用于我的项目中的每个布局
  • Cython:使用嵌套 typedef 公开 C++ 类

    根据this https stackoverflow com questions 28382575 are c style internal typedefs possible in cythonstackoverflow 中的问题 答案
Powered by Hwhale