Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X_PACK_FLAG_ATTR传进去后似乎没用起作用 #44

Open
younif opened this issue Nov 29, 2023 · 8 comments
Open

X_PACK_FLAG_ATTR传进去后似乎没用起作用 #44

younif opened this issue Nov 29, 2023 · 8 comments

Comments

@younif
Copy link

younif commented Nov 29, 2023

用的是clion自带的mingw11.0

@younif
Copy link
Author

younif commented Nov 29, 2023

另外结构体内的变量似乎过多的话会报错,编译不通过

@xyz347
Copy link
Owner

xyz347 commented Nov 29, 2023

X_PACK_FLAG_ATTR不生效的给一下范例
变量过多的问题,一个O最多支持99个变量,如果变量太多,可以放多个O(A、M等类似)

@younif
Copy link
Author

younif commented Nov 29, 2023

#include <iostream>
#include "xpack/xml.h"
using namespace std;
struct User {
    int id;
    string  name;
XPACK(O(id, name));
};
int main(int argc, char *argv[]) {
    User u;
    u.id = 12;
    u.name = "uname";

    std::string xmlData_b = xpack::xml::encode(u,"root", X_PACK_FLAG_ATTR , 4, ' ');

    std::cout << "Encoded XML:\n" << xmlData_b << "\n\n";

    return 0;
}

这个是测试代码
输出的是

Encoded XML:

<root>
    <id>12</id>
    <name>uname</name>
</root>

Process finished with exit code 0

@younif
Copy link
Author

younif commented Nov 29, 2023

我在打断点的时候,发现在判断X_PACK_FLAG_ATTR时,对应的变量变成了0

@younif
Copy link
Author

younif commented Nov 29, 2023

X_PACK_FLAG_ATTR不生效的给一下范例 变量过多的问题,一个O最多支持99个变量,如果变量太多,可以放多个O(A、M等类似)

谢谢你!

@xyz347
Copy link
Owner

xyz347 commented Nov 29, 2023

目前encode传入的flag不生效,需要用X(F(ATTR), id)这种写法

@ButteredCat
Copy link

支持decode XML中的attribute吗?

@xyz347
Copy link
Owner

xyz347 commented May 9, 2024

支持

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants